How can i change an NPX script to run with NPM or node so it does not download modules each run?

Viewed 11

I have an NPX script that runs with the following:

npx ts-node ./src/propose-tx.ts

However this downloads the modules each run, i would like to just run npm install and then execute the script locally with npm start or nodemon start so i can run it when there is no internet access.

How can i achieve this? This is package.json:

{
  "version": "1.0.0",
  "main": "lib/propose-tx.js",
  "types": "lib/propose-tx.d.ts",
  "bin": "./lib/propose-tx.js",
  "scripts": {
    "start": "ts-node ./src/propose-tx.ts",
    "build": "tsc",
    "format": "prettier --write \"src/**/*.(js|ts)\"",
    "lint": "eslint src --ext .js,.ts",
    "lint:fix": "eslint src --fix --ext .js,.ts",
    "prepare": "npm run build",
    "prepublishOnly": "npm run lint",
    "preversion": "npm run lint",
    "version": "npm run format && git add -A src",
    "postversion": "git push && git push --tags"
  },
  "dependencies": {
    "axios": "0.27.2",
    "bignumber.js": "9.1.0",
    "eth-typed-data": "0.1.0-beta.0",
    "ethereumjs-util": "7.1.5",
    "ethers": "5.7.0",
    "read": "1.0.7",
    "yargs": "17.5.1"
  },
  "devDependencies": {
    "@types/read": "0.0.29",
    "@types/yargs": "17.0.11",
    "@typescript-eslint/eslint-plugin": "5.30.7",
    "@typescript-eslint/parser": "5.30.7",
    "eslint": "8.20.0",
    "prettier": "2.7.1",
    "ts-node": "10.9.1",
    "typescript": "4.7.4"
  },
  "files": [
    "lib/**/*"
  ]
}
0 Answers
Related