question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nodemon can't find ts-node when running with npm 7+

See original GitHub issue
  • nodemon -v: 2.0.7
  • node -v: v15.14.0
  • Operating system/terminal environment: Windows 10, Git Bash/Mintty
  • Using Docker? What image: N/A
  • Command you ran: npm start -> nodemon src/main.ts

Expected behavior

Application should start normally and be watched by Nodemon.

Actual behavior

[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: ts,json      
[nodemon] starting `ts-node src/main.ts`    
'ts-node' is not recognized as an internal or external command,
operable program or batch file.
[nodemon] app crashed - waiting for file changes before starting...

Steps to reproduce

Run nodemon through npm 7.


If applicable, please append the --dump flag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.

Dump ``` [nodemon] 2.0.7 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,json -------------- node: v15.14.0 nodemon: 2.0.7 command: C:\Program Files\nodejs\node.exe C:\git\waw\server\node_modules\nodemon\bin\nodemon.js --dump cwd: C:\git\waw\server OS: win32 x64 -------------- { run: false, system: { cwd: 'C:\\git\\waw\\server' }, required: false, dirs: [ 'C:\\git\\waw\\server' ], timeout: 1000, options: { dump: true, ignore: [ '**/.git/**', '**/.nyc_output/**', '**/.sass-cache/**', '**/bower_components/**', '**/coverage/**', '**/node_modules/**', re: /.*.*\/\.git\/.*.*|.*.*\/\.nyc_output\/.*.*|.*.*\/\.sass\-cache\/.*.*|.*.*\/bower_components\/.*.*|.*.*\/coverage\/.*.*|.*.*\/node_modules\/.*.*/ ], watch: [ '*.*', re: /.*\..*/ ], monitor: [ '*.*', '!**/.git/**', '!**/.nyc_output/**', '!**/.sass-cache/**', '!**/bower_components/**', '!**/coverage/**', '!**/node_modules/**' ], ignoreRoot: [ '**/.git/**', '**/.nyc_output/**', '**/.sass-cache/**', '**/bower_components/**', '**/coverage/**', '**/node_modules/**' ], restartable: 'rs', colours: true, execMap: { py: 'python', rb: 'ruby', ts: 'ts-node' }, stdin: true, runOnChangeOnly: false, verbose: false, signal: 'SIGUSR2', stdout: true, watchOptions: {}, execOptions: { script: 'main.js', exec: 'node', args: [], scriptPosition: 0, nodeArgs: undefined, execArgs: [], ext: 'js,mjs,json', env: {} } }, load: [Function (anonymous)], reset: [Function: reset], lastStarted: 0, loaded: [], watchInterval: null, signal: 'SIGUSR2', command: { raw: { executable: 'node', args: [ 'main.js' ] }, string: 'node main.js' } } ```

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
TheLordDrakecommented, May 3, 2021

According to your given code output sample this should work. "watch": "nodemon --exec \"npm run tsnode\"" Otherwise try install ts-node globally is also an option.

This works as a work around. Doesn’t solve the the issue but it’ll keep people moving. I would not install any package globally unless you want a consistent version in all projects. (Or it’s a cli tool)

"watch": "nodemon --exec \"npm run tsnode\"",
"tsnode": "ts-node src/main.ts"
2reactions
sadiqhabibcommented, May 3, 2021

According to your given code output sample this should work. "watch": "nodemon --exec \"npm run tsnode\"" Otherwise try install ts-node globally is also an option.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'ts-node' is not recognized as an internal or external command ...
1) Install nodemon locally --> npm i nodemon · 2) In your package. · 3) Now run npm start (this will automatically run...
Read more >
ts-node - npm
Start using ts-node in your project by running `npm i ts-node`. ... If no tsconfig.json is loaded from disk, ts-node will use the...
Read more >
Cannot find module 'ts-node/register' Error in TypeScript
To solve the error "Cannot find module 'ts-node/register'", install ts-node and typescript as development dependencies by running npm install --save-dev ...
Read more >
Configuring nodemon with TypeScript - LogRocket Blog
As of v1.19.0, nodemon has inbuilt support for TypeScript files with help from ts-node that requires no manual configuration.
Read more >
A Complete Guide to Using TypeScript in Node.js - Better Stack
Integrating TypeScript with the NPM ecosystem. Executing TypeScript source files directly without compilation. Fixing errors caused by missing types.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found