Installed with npm i -g ts-node
Test run with ts-node ~/tmp/test.ts
Output:
Error: Cannot find module 'typescript'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.register (/Users/polyergic/.npm-global/lib/node_modules/ts-node/src/index.ts:175:25)
at Object.<anonymous> (/Users/polyergic/.npm-global/lib/node_modules/ts-node/src/_bin.ts:144:17)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
Content of ~/tmp/test.ts:
#!/usr/bin/env ts-node
console.log( "Hello ts-node!" );
It turned out typescript was not installed - I could have sworn it was, but I was mistaken.
After npm i -g typescript it seems to work; output of both ts-node ~/tmp/test.ts and ~/tmp/test.ts is Hello ts-node!.
Please add typescript as a dependency in package.json.
Installed with
npm i -g ts-nodeTest run with
ts-node ~/tmp/test.tsOutput:
Content of
~/tmp/test.ts:It turned out typescript was not installed - I could have sworn it was, but I was mistaken.
After
npm i -g typescriptit seems to work; output of bothts-node ~/tmp/test.tsand~/tmp/test.tsisHello ts-node!.Please add typescript as a dependency in package.json.