typescript-book icon indicating copy to clipboard operation
typescript-book copied to clipboard

NodeJS QuickStart step 4 produces error

Open fultonm opened this issue 8 years ago • 7 comments

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>

fultonm avatar Dec 22 '16 01:12 fultonm

Please use bash (e.g. the one that comes with git) :rose:

basarat avatar Jan 03 '17 04:01 basarat

That doesn't work in Windows 10

Workaround:

  1. Install typescript globally: npm install typescript -g
  2. In Windows Command Console or Git Bash execute: tsc --init

alex-pollan avatar Jan 08 '17 09:01 alex-pollan

Fixed it : https://github.com/basarat/typescript-book/commit/3da932e40dcee9c54e1520b646bc6f66458dcfb8 so you don't need bash anymore :rose:

basarat avatar Jan 09 '17 02:01 basarat

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 avatar Jan 09 '17 17:01 alex-pollan

@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:

basarat avatar Jan 09 '17 20:01 basarat

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",

toneeraj avatar Mar 19 '17 00:03 toneeraj

@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).

blakeembrey avatar Mar 19 '17 02:03 blakeembrey