node.js - npm nodejs project with typescript; live build doesn't recompile changed modules -


i found description init nodejs project in typescript here: https://basarat.gitbooks.io/typescript/docs/quick/nodejs.html

this describes way autorecompile onchange, if run code using npm start.

i created project configuration:

tsconfig.json:

{   "compileroptions": {     /* basic options */     "target": "es2015",                          /* specify ecmascript target version: 'es3' (default), 'es5', 'es2015', 'es2016', 'es2017', or 'esnext'. */     "module": "commonjs",                     /* specify module code generation: 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'esnext'. */      "outdir": "./build",                        /* redirect output structure directory. */     /* strict type-checking options */     "strict": true                            /* enable strict type-checking options. */   },   "files":[     "server.ts",     "db/db.ts",     "protocol/protocol.ts"   ]  } 

package.json

{   "name": "server",   "version": "1.0.0",   "description": "",   "main": "server.js",   "scripts": {     "start": "npm run build:live",     "build:live": "nodemon --exec node_modules\\.bin\\ts-node -- server.ts",     "test": "echo \"error: no test specified\" && exit 1"   },   "keywords": [],   "author": "",   "license": "isc",   "dependencies": {     "typescript": "^2.4.2"   },   "devdependencies": {     "@types/express": "^4.0.36",     "@types/node": "^8.0.20",     "express": "^4.15.4",     "mysql": "^2.14.1",     "nodemon": "^1.11.0",     "ts-node": "^3.3.0",     "typescript": "^2.4.2"   } } 

the reload works fine, if change mainfile server.ts

problem

if change db.ts or protocol.ts, reload performed, db.ts , protocol.ts not recompiled.

any ideas?

i not recommend using nodemon , ts-node dev, instead recommend using tsc-watch.

npm install tsc-watch --save-dev

and in package.json should this:

  "scripts": {     "start": "node ./build/server.js",     "build": "tsc",     "dev": "tsc-watch --onsuccess \"node ./build/server.js\"",   } 
  • build building app ready production.
  • start starting app on production.
  • dev compiling , running/re-running node.

remark: script can run using "npm run dev"


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -