I know it has been covered in different questions but mine is a bit different: Sorry in advance if it sounds really noob.
this is the script in package.json:
"start": "nodemon ./index.js --exec \"node -r babel-register\"",
I replaced by :
"start": "node scripts/start.js",
and in start.js, i do :
const { execSync } = require('child_process')
execSync('nodemon ../index.js --exec \"node -r babel-register\"')
wich throw an error :
/bin/sh: nodemon: command not found
Am I right with "execSync" ?
I tried import nodemon in the file but it obviously not helping
What you're doing should work if nodemon
is installed globally, ie with:
npm install -g nodemon
But if it's installed as a project dependency, ie with:
npm install --save-dev nodemon
Then you'll need to run it from the directory containing all the locally installed binaries: node_modules/.bin/
So something like this should work:
execSync('./node_modules/.bin/nodemon ../index.js --exec \"node -r babel-register\"')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.