typescript-book
typescript-book copied to clipboard
NodeJS QuickStart step 4 produces error
What am I doing wrong in my command? I am on Windows 10.
PS D:\proj\tsnode> node ./node_modules/.bin/tsc --init D:\proj\tsnode\node_modules.bin\tsc:2 basedir=$(dirname "$(echo "$0" | sed -e 's,\,/,g')") ^^^^^^^ SyntaxError: missing ) after argument list at Object.exports.runInThisContext (vm.js:78:16) at Module._compile (module.js:543:28) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.runMain (module.js:605:10) at run (bootstrap_node.js:420:7) at startup (bootstrap_node.js:139:9) at bootstrap_node.js:535:3 PS D:\proj\tsnode>
Please use bash (e.g. the one that comes with git) :rose:
That doesn't work in Windows 10
Workaround:
- Install typescript globally:
npm install typescript -g - In Windows Command Console or Git Bash execute:
tsc --init
Fixed it : https://github.com/basarat/typescript-book/commit/3da932e40dcee9c54e1520b646bc6f66458dcfb8 so you don't need bash anymore :rose:
This code:
"build:live": "nodemon --exec ./node_modules/.bin/ts-node -- ./index.ts"
fails too in Windows 10. You'd probably want to apply the same fix to it.
@alex-pollan I actually got frustrated with nodemon so much that I wrote https://github.com/basarat/starts over the weekend :rose:
Will think it through. Thanks for raising :heart:
I am in windows 8 and each time it nodemon was crashing. Here is my workaround
Installed ts-node globally
npm install -g ts-node
This code:
"build:live": "nodemon --exec ./node_modules/.bin/ts-node -- ./index.ts"
changed to
"build:live": "nodemon --exec ts-node index.ts",
@alex-pollan @basarat If it's in an NPM script, you could just keep it as ts-node since npm corrects the PATH to the local node modules during execution. Aside from that, you can also try https://www.npmjs.com/package/onchange (it'd do basically the same job as nodemon, but in a more generic way - it's what I usually use for re-loading node projects).