I have this script which works well
"start": "nodemon -x node -r dotenv/config src/index.js"
I want use babel-node instead node. So there is the new script:
"start": "nodemon -x babel-node --presets=env -r dotenv/config -- src/index.js"
But I get this error
[nodemon] starting `babel-node --presets=env -r dotenv/config src/index.js`
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module 'pathTo/dotenv/config'
Can you help ?
This worked for me
"start": "nodemon --exec babel-node -r node_modules/dotenv/config index.js"
This issues existed for a short time in babel. @babel/node cannot seem to resolve node modules, when using --require flag
"start": "nodemon --exec babel-node -r ./node_modules/dotenv/config src/index.js"
This issue has now been resolved. Allow -r from node_modules with @babel/node
"start": "nodemon --exec babel-node -r dotenv/config src/index.js"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With