Reputation: 363
I am trying to use babel-node
to run files in my node
project.
I am able to get them running if I set up an npm script
, such as:
"scripts": {
"start": "babel-node src/index.js"
},
However, if I try to run it via the cli, I get the error: zsh: command not found: babel-node
.
I've already tried installing babel-node
both globally, and as a dev-dependency, via:
npm i -g @babel/node @babel/cli
But this hasn't worked for me.
Does anyone know why the shell command doesn't work?
Upvotes: 0
Views: 517
Reputation: 2462
per https://babeljs.io/docs/babel-node
Compile and run test.js.
Shell
npx babel-node test
so you should update your script to
"scripts": {
"start": "npx babel-node src/index.js"
},
And you should be able to lose the /index.js
part, simplifying to
"scripts": {
"start": "npx babel-node src"
},
Upvotes: 2