npm run dev function gives me error in my ubuntu os - node.js

When i run npm run dev function it gives me this, just before a day ago it was working correctly, can anyone please help me why i am getting this error ? this is my full error response, can anyone please look at this response, and help me what's exact issue in it ? any help will be really appreciated, i spent lots of hours to resolve this issue but didn't help me,
> mern-auth#1.0.0 dev /var/www/mern-plaid
> concurrently "npm run server" "npm run client"
[0]
[0] > mern-auth#1.0.0 server /var/www/mern-plaid
[0] > nodemon server.js
[0]
[1]
[1] > mern-auth#1.0.0 client /var/www/mern-plaid
[1] > npm start --prefix client
[1]
[0] [nodemon] 1.19.1
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching: *.*
[0] [nodemon] starting `node server.js`
[1]
[1] > client#0.1.0 start /var/www/mern-plaid/client
[1] > react-scripts start
[1]
[1]
[1] There might be a problem with the project dependency tree.
[1] It is likely not a bug in Create React App, but something you need to fix locally.
[1]
[1] The react-scripts package provided by Create React App requires a dependency:
[1]
[1] "babel-eslint": "9.0.0"
[1]
[1] Don't try to install it manually: your package manager does it automatically.
[1] However, a different version of babel-eslint was detected higher up in the tree:
[1]
[1] /var/www/mern-plaid/client/node_modules/babel-eslint (version: 10.0.3)
[1]
[1] Manually installing incompatible versions is known to cause hard-to-debug issues.
[1]
[1] If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
[1] That will permanently disable this message but you might encounter other issues.
[1]
[1] To fix the dependency tree, try following the steps below in the exact order:
[1]
[1] 1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
[1] 2. Delete node_modules in your project folder.
[1] 3. Remove "babel-eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
[1] 4. Run npm install or yarn, depending on the package manager you use.
[1]
[1] In most cases, this should be enough to fix the problem.
[1] If this has not helped, there are a few other things you can try:
[1]
[1] 5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
[1] This may help because npm has known issues with package hoisting which may get resolved in future versions.
[1]
[1] 6. Check if /var/www/mern-plaid/client/node_modules/babel-eslint is outside your project directory.
[1] For example, you might have accidentally installed something in your home folder.
[1]
[1] 7. Try running npm ls babel-eslint in your project folder.
[1] This will tell you which other package (apart from the expected react-scripts) installed babel-eslint.
[1]
[1] If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
[1] That would permanently disable this preflight check in case you want to proceed anyway.
[1]
[1] P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
[1]
[1] npm ERR! code ELIFECYCLE
[1] npm ERR! errno 1
[1] npm ERR! client#0.1.0 start: `react-scripts start`
[1] npm ERR! Exit status 1
npm ERR!
[1] npm ERR! Failed at the client#0.1.0 start script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[0] Server up and running on port 5000 !
[1]
[1] npm ERR! A complete log of this run can be found in:
[1] npm ERR! /root/.npm/_logs/2019-08-26T10_33_27_229Z-debug.log
[1] npm ERR! code ELIFECYCLE
npm ERR! errno 1
[1] npm ERR! mern-auth#1.0.0 client: `npm start --prefix client`
[1] npm ERR! Exit status 1
npm ERR!
[1] npm ERR! Failed at the mern-auth#1.0.0 client script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[1]
[1] npm ERR! A complete log of this run can be found in:
[1] npm ERR! /root/.npm/_logs/2019-08-26T10_33_27_278Z-debug.log
[1] npm run client exited with code 1
[0] MongoDB successfully connected
package.json
{
"name": "mern-auth",
"version": "1.0.0",
"description": "Mern Auth Example",
"main": "server.js",
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
"author": "",
"license": "MIT",
"dependencies": {
"babel-eslint": "^10.0.3",
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.3",
"concurrently": "^4.0.1",
"express": "^4.16.4",
"is-empty": "^1.2.0",
"jsonwebtoken": "^8.3.0",
"moment": "^2.24.0",
"mongoose": "^5.3.11",
"nodemon": "^1.19.1",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"plaid": "^4.2.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-scripts": "^3.1.1",
"validator": "^10.9.0"
}
}

In npm if you know the exact version of the package needed, y, you can append it to the package name after the # character.
In your case react needs the version of 9.0.0 so, you need to uninstall your babel-eslint
v. 10.0.3 and install v. 9.0.0.
npm uninstall babel-eslint --save
npm install --save babel-eslint#9.0.0

Related

React App wont run using npm run dev, by use of concurrently

I am working on a React app that I just pulled down from Github. I ran an npm ci once pulled down and opened the project hoping it would run. I'm getting an error when I am trying to run the client and server using npm run dev by use of concurrently.
What I'm not understanding is other developers have opened the project and have no problem getting the project to run. Is there a problem with my computer's configuration or is this an npm issue?
Error Message:
[1] > PFP-Skeleton#1.0.0 client /Users/sam/Desktop/SchoolFolder/Capstone/march17/PrestonFoodBank
[1] > npm start --prefix client
[1]
[0]
[0] > PFP-Skeleton#1.0.0 server /Users/sam/Desktop/SchoolFolder/Capstone/march17/PrestonFoodBank
[0] > nodemon server.js
[0]
[0] [nodemon] 2.0.15
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching path(s): *.*
[0] [nodemon] watching extensions: js,mjs,json
[0] [nodemon] starting `node server.js app.js`
[1]
[1] > multipage-site#0.1.0 start /Users/sam/Desktop/SchoolFolder/Capstone/march17/PrestonFoodBank/client
[1] > react-scripts start
[1]
[1] sh: react-scripts: command not found
[1] npm ERR! code ELIFECYCLE
[1] npm ERR! syscall spawn
[1] npm ERR! file sh
npm ERR! errno ENOENT
[1] npm ERR! multipage-site#0.1.0 start: `react-scripts start`
[1] npm ERR! spawn ENOENT
[1] npm ERR!
[1] npm ERR! Failed at the multipage-site#0.1.0 start script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[1] npm WARN Local package.json exists, but node_modules missing, did you mean to install?
[1]
[1] npm ERR! A complete log of this run can be found in:
[1] npm ERR! /Users/sam/.npm/_logs/2022-03-17T20_08_54_290Z-debug.log
[1] npm ERR! code ELIFECYCLE
[1] npm ERR! errno 1
[1] npm ERR! PFP-Skeleton#1.0.0 client: `npm start --prefix client`
[1] npm ERR! Exit status 1
[1] npm ERR!
[1] npm ERR! Failed at the PFP-Skeleton#1.0.0 client script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[1]
npm ERR! A complete log of this run can be found in:
[1] npm ERR! /Users/sam/.npm/_logs/2022-03-17T20_08_54_325Z-debug.log
[1] npm run client exited with code 1
[0] server up on http://localhost:5001
[0] Executing (default): SELECT 1+1 AS result
[0] Database synced
package.json:
{
"name": "PFP-Skeleton",
"version": "1.0.0",
"description": "",
"main": "app.js",
"dependencies": {
"bcrypt": "^5.0.1",
"config": "^3.3.7",
"cors": "^2.8.5",
"express": "^4.17.2",
"jsonwebtoken": "^8.5.1",
"pg": "^8.7.3",
"pg-hstore": "^2.3.4",
"sequelize": "^6.16.1",
"tedious": "^14.3.0"
},
"devDependencies": {
"concurrently": "^7.0.0",
"nodemon": "^2.0.15"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"clientinstall": "npm install --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
"keywords": [],
"author": "",
"license": "ISC"
}

Unable to deploy application on heroku

I am receiving the following error while deploying my application on heroku, I have deployed it before with no problems. I also have not changed the package.json file, so I am unsure why I am getting the following error.
There are no additional configs for heroku, the application was previously deployed, and cannot be updated.
The application is deployed currently under a previous version through the heroku website from my github.
Any help to resolve this issue would be greatly appreciated!
error from heroku
-----> Build
Running heroku-postbuild
> operations-reporting#1.0.0 heroku-postbuild /tmp/build_04594e22478b41fb98f830b9b12c2400
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
added 86 packages from 287 contributors and audited 906755 packages in 16.658s
found 2 moderate severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
> client#0.1.0 build /tmp/build_04594e22478b41fb98f830b9b12c2400/client
> react-scripts build
internal/modules/cjs/loader.js:800
throw err;
^
Error: Cannot find module 'es-abstract/2019/CreateDataProperty'
Require stack:
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/implementation.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/index.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/util.promisify/implementation.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/util.promisify/index.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/html-webpack-plugin/index.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/react-scripts/config/webpack.config.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/react-scripts/scripts/build.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/implementation.js:3:26)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/implementation.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/index.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/util.promisify/implementation.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/util.promisify/index.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/html-webpack-plugin/index.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/react-scripts/config/webpack.config.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/react-scripts/scripts/build.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.PQkmQ/_logs/2019-12-14T21_42_39_533Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! operations-reporting#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the operations-reporting#1.0.0 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.PQkmQ/_logs/2019-12-14T21_42_39_547Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- node_modules checked into source control
https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
package.json
{
"name": "client",
"version": "0.1.0",
"main": "index.js",
"private": true,
"dependencies": {
"axios": "^0.19.0",
"config": "^3.2.4",
"express": "^4.17.1",
"express-validator": "^6.3.0",
"formik": "^2.0.6",
"mongoose": "^5.7.12",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.2.0",
"react-table": "^6.10.3",
"reactstrap": "^8.1.1",
"schema-utils": "^2.6.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"concurrently": "^5.0.0",
"nodemon": "^2.0.1"
},
"proxy": "http://localhost:5000"
}
Find the missing module and update your package like so:
npm install --save --save-exact foo#1.2.3
This is from heroku
Other solution:
heroku config:set NODE_MODULES_CACHE=false

Why does "npm start" give me error when i try run my app?

i dont understand why i got this error every
time when i try run "npm start".
> # start E:\ReactNative\navigation_app
> expo start
internal/modules/cjs/loader.js:895
throw err;
^
Error: Cannot find module 'C:\Users\Roei\AppData\Roaming\npm\node_modules\expo-cli\bin\expo.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:892:15)
at Function.Module._load (internal/modules/cjs/loader.js:785:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:1143:12)
at internal/main/run_main_module.js:16:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # start: `expo start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Roei\AppData\Roaming\npm-cache\_logs\2019-11-16T17_19_40_408Z-debug.log
this is my package.json and try
to figure out whats wrong there
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"expo": "^35.0.0",
"expo-font": "^7.0.0",
"react": "16.8.3",
"react-dom": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
"react-native-web": "^0.11.7"
},
"devDependencies": {
"babel-preset-expo": "^7.1.0"
},
"private": true
}
i would like to solve that issue and to understand whats worng .
You need to install expo-cli globally npm i -g expo-cli
you need to install Expo. Run an npm install or install expo globally
You don't have Expo-CLI installed globally, that is why you are getting the error at your local project. It needs Expo module to work, but can't find it. So run npm install -g expo-cli as it has been said, if it does not install paste the error code here.

babel-node is not getting installed on Heroku

I'm using babel-node for ES6 syntax on Heroku, but I get a build error when I deploy. It says "babel-node: not found". I've tried a clean install on my local computer and it works perfectly. Package.json:
{
"name": "secret",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "./node_modules/.bin/babel-node ./bin/www"
},
"engines": {
"node": "7.5.0",
"npm": "5.0.3"
},
"dependencies": {
"babel-cli": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
...
}
}
I appreciate your help! :)
2017-07-17T11:02:26.997876+00:00 heroku[web.1]: State changed from crashed to starting
2017-07-17T11:02:31.839278+00:00 heroku[web.1]: Starting process with command `npm start`
2017-07-17T11:02:38.074157+00:00 heroku[web.1]: State changed from starting to crashed
2017-07-17T11:02:38.062607+00:00 heroku[web.1]: Process exited with status 1
2017-07-17T11:02:37.865774+00:00 app[web.1]:
2017-07-17T11:02:37.865786+00:00 app[web.1]: > secret#0.0.0 start /app
2017-07-17T11:02:37.865787+00:00 app[web.1]: > babel-node ./bin/www
2017-07-17T11:02:37.865787+00:00 app[web.1]:
2017-07-17T11:02:37.936361+00:00 app[web.1]: sh: 1: babel-node: not found
2017-07-17T11:02:37.966452+00:00 app[web.1]: npm ERR! file sh
2017-07-17T11:02:37.966683+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-07-17T11:02:37.966931+00:00 app[web.1]: npm ERR! errno ENOENT
2017-07-17T11:02:37.967106+00:00 app[web.1]: npm ERR! syscall spawn
2017-07-17T11:02:37.967287+00:00 app[web.1]: npm ERR! secret#0.0.0 start: `babel-node ./bin/www`
2017-07-17T11:02:37.967430+00:00 app[web.1]: npm ERR! spawn ENOENT
2017-07-17T11:02:37.967588+00:00 app[web.1]: npm ERR!
2017-07-17T11:02:37.967733+00:00 app[web.1]: npm ERR! Failed at the secret#0.0.0 start script.
2017-07-17T11:02:37.967873+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2017-07-17T11:02:37.969151+00:00 app[web.1]:
2017-07-17T11:02:37.969374+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-07-17T11:02:37.969484+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2017-07-17T11_02_37_957Z-debug.log
2017-07-17T11:25:52.044791+00:00 heroku[web.1]: State changed from crashed to starting
2017-07-17T11:25:54.841341+00:00 heroku[web.1]: Starting process with command `npm start`
2017-07-17T11:25:57.407691+00:00 heroku[web.1]: Process exited with status 1
2017-07-17T11:25:57.413873+00:00 heroku[web.1]: State changed from starting to crashed
2017-07-17T11:25:57.310176+00:00 app[web.1]:
2017-07-17T11:25:57.310190+00:00 app[web.1]: > secret#0.0.0 start /app
2017-07-17T11:25:57.310191+00:00 app[web.1]: > babel-node ./bin/www
2017-07-17T11:25:57.310192+00:00 app[web.1]:
2017-07-17T11:25:57.316940+00:00 app[web.1]: sh: 1: babel-node: not found
2017-07-17T11:25:57.335019+00:00 app[web.1]: npm ERR! file sh
2017-07-17T11:25:57.335287+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-07-17T11:25:57.335517+00:00 app[web.1]: npm ERR! errno ENOENT
2017-07-17T11:25:57.335735+00:00 app[web.1]: npm ERR! syscall spawn
2017-07-17T11:25:57.335933+00:00 app[web.1]: npm ERR! secret#0.0.0 start: `babel-node ./bin/www`
2017-07-17T11:25:57.336095+00:00 app[web.1]: npm ERR! spawn ENOENT
2017-07-17T11:25:57.336280+00:00 app[web.1]: npm ERR!
2017-07-17T11:25:57.336449+00:00 app[web.1]: npm ERR! Failed at the secret#0.0.0 start script.
2017-07-17T11:25:57.336614+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2017-07-17T11:25:57.337985+00:00 app[web.1]:
2017-07-17T11:25:57.338232+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-07-17T11:25:57.338379+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2017-07-17T11_25_57_323Z-debug.log
babel-node is "not meant for production use". There is a more relevant guide here for using #babel/cli, #babel/core and #babel/preset-env.
The babel dependencies should all be installed as devDependencies and you should transpile your code during in a build script run before Heroku prunes the devDependencies. See this guide
If you move all of your es6 code into a common directory like src at the top level of your app, you can create a build script to transpile everything in that directory to an output directory like build.
"build": "npm run clean && npm run build-babel",
"build-babel": "./node_modules/.bin/babel -d ./build ./src",
"clean": "rm -rf build && mkdir build",
In the example above, the build script will be run automatically by Heroku. clean will create a new build directory, and build-babel will transpile the code and place it in the build directory. After this is completed, Heroku will prune the devDependencies, but you will no longer need Babel.
When Heroku calls start below, it will be running your transpiled code. You should no longer see sh: 1: babel-node: not found.
"scripts": {
"build": "npm run clean && npm run build-babel",
"build-babel": "./node_modules/.bin/babel -d ./build ./src",
"clean": "rm -rf build && mkdir build",
"start": "node ./build/bin/www"
},
One potential gotcha, Do not call build from your start script. If you do, the devDependencies will have been pruned and you will get the following
sh: 1: babel: not found
A little bit late, but here is what I think you are missing:
Step (1): npm install --save babel-cli babel-preset-env in terminal
Note on step 1: Do not save to dev as that will require you to set NPM_CONFIG_PRODUCTION=false
Step (2): You are not compiling anything to babel without adding in the babel boilerplate and or using a babelrc file. Easiest method is to make a .babelrc file in your main app folder, ie. same one your package.json is in and input the following:
{
"presets": ["env"]
}
Note on step 2: With the usage of the env preset you do not need the babel-preset-es2015, etc
Step (3): You can now run your code using babel-node, so in your case execute your start script, ie. ./node_modules/.bin/babel-node ./bin/www
I suggest reading through the NPM module if you need further guidance understanding the preset logic: https://www.npmjs.com/package/babel-preset-env
Furthermore, I would suggest using a process manager like pm2. This allows your node instance to keep alive if it crashes. The forever module used to do this but pm2 is way better. Here is an example of a start script inside your package.json:
"scripts": {
"start": "node ./node_modules/.bin/pm2 start main.json --attach --env production"
}
Procfile (note, I am using nginx but just npm start would work fine):
web: bin/start-nginx npm start
worker: node ./node_modules/.bin/pm2 start worker.json --attach
And here would be your main.json with args to use babel-node (note, keep instance to 1 and do not fork on a web dyno in Heroku):
main.json:
{
"name": "the_awesome",
"script": "app.js",
"instances": 1,
"exec_mode": "cluster"
}
worker.json:
{
"name": "worker",
"script": "/app/lib/worker.js"
}
(4) Add a require('babel-register') hook to your app.js and worker.js if you are using pm2 in cluster mode. If you are using pm2 not in cluster mode, or just not using pm2 then you can use babel-node directly to run your .js or es6 files
Finally, to check if babel-node is really installed you can do the following:
heroku run bash -a {name of your app}
ls ./node_modules/.bin //babel-node should be present
Good luck!

package.json start script, babel-node: not found on heroku deploy

When I run heroku local or when I just do npm start locally, my app builds and runs fine. However when I deploy to heroku, the app crashes saying it cannot find babel-node.
Here is the log output:
2016-04-21T22:20:44.320025+00:00 heroku[api]: Deploy 5d9a9da by eagsalazar#gmail.com
2016-04-21T22:20:44.320084+00:00 heroku[api]: Release v9 created by eagsalazar#gmail.com
2016-04-21T22:20:44.542062+00:00 heroku[slug-compiler]: Slug compilation started
2016-04-21T22:20:44.542069+00:00 heroku[slug-compiler]: Slug compilation finished
2016-04-21T22:20:44.501025+00:00 heroku[web.1]: State changed from crashed to starting
2016-04-21T22:20:46.278065+00:00 heroku[web.1]: Starting process with command `npm start`
2016-04-21T22:20:50.467407+00:00 app[web.1]:
2016-04-21T22:20:50.467434+00:00 app[web.1]: > qc-server#1.0.0 start /app
2016-04-21T22:20:50.467435+00:00 app[web.1]: > babel-node index.js
2016-04-21T22:20:50.467436+00:00 app[web.1]:
2016-04-21T22:20:50.479490+00:00 app[web.1]: sh: 1: babel-node: not found
2016-04-21T22:20:50.521936+00:00 app[web.1]:
2016-04-21T22:20:50.538822+00:00 app[web.1]: npm ERR! Linux 3.13.0-79-generic
2016-04-21T22:20:50.539334+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-04-21T22:20:50.539595+00:00 app[web.1]: npm ERR! node v5.10.1
2016-04-21T22:20:50.555119+00:00 app[web.1]: npm ERR! npm v3.8.3
2016-04-21T22:20:50.555339+00:00 app[web.1]: npm ERR! file sh
2016-04-21T22:20:50.555549+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2016-04-21T22:20:50.555769+00:00 app[web.1]: npm ERR! errno ENOENT
2016-04-21T22:20:50.555965+00:00 app[web.1]: npm ERR! syscall spawn
2016-04-21T22:20:50.556142+00:00 app[web.1]: npm ERR! qc-server#1.0.0 start: `babel-node index.js`
2016-04-21T22:20:50.556305+00:00 app[web.1]: npm ERR! spawn ENOENT
2016-04-21T22:20:50.556488+00:00 app[web.1]: npm ERR!
2016-04-21T22:20:50.556666+00:00 app[web.1]: npm ERR! Failed at the qc-server#1.0.0 start script 'babel-node index.js'.
2016-04-21T22:20:50.556854+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2016-04-21T22:20:50.557017+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the qc-server package,
2016-04-21T22:20:50.557175+00:00 app[web.1]: npm ERR! not with npm itself.
2016-04-21T22:20:50.557343+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2016-04-21T22:20:50.557564+00:00 app[web.1]: npm ERR! babel-node index.js
2016-04-21T22:20:50.557741+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2016-04-21T22:20:50.557916+00:00 app[web.1]: npm ERR! npm bugs qc-server
2016-04-21T22:20:50.558110+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2016-04-21T22:20:50.558306+00:00 app[web.1]: npm ERR! npm owner ls qc-server
2016-04-21T22:20:50.558492+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2016-04-21T22:20:50.563859+00:00 app[web.1]:
2016-04-21T22:20:50.567790+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-04-21T22:20:50.568004+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2016-04-21T22:20:51.824822+00:00 heroku[web.1]: State changed from starting to crashed
2016-04-21T22:20:51.808246+00:00 heroku[web.1]: Process exited with status 1
My package.json:
{
"name": "qc-server",
"version": "1.0.0",
"description": "xxxx",
"main": "index.js",
"scripts": {
"test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js 'test/**/*.js'",
"test:watch": "npm run test -- --watch -G",
"start": "babel-node index.js"
},
"babel": {
"presets": [
"es2015"
]
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.6.0",
"babel-core": "^6.6.0",
"babel-eslint": "^5.0.0",
"babel-preset-es2015": "^6.6.0",
"chai": "^3.5.0",
"chai-immutable": "^1.5.3",
"eslint": "^2.2.0",
"eslint-config-airbnb": "^6.0.2",
"eslint-plugin-react": "^4.1.0",
"mocha": "^2.4.5"
},
"dependencies": {
"express": "^4.13.4",
"immutable": "^3.7.6",
"node-uuid": "^1.4.7",
"redux": "^3.3.1",
"socket.io": "^1.4.5"
}
}
Anyone have suggestions?
You have to include the dependency in you package.json so it will install it when you deploy.
$ npm install babel-cli -S
Than you have to change you start command to be like:
"start": "babel-node index.js"
See here for more info on deploying babel on heroku.com.
Warning: using babel-node is not recommended in production
I got the same issue, but I think set NPM_CONFIG_PRODUCTION=false to install devDependencies will be better. I used below command:
heroku config:set NPM_CONFIG_PRODUCTION=false
Specifically, include the necessary dependency under 'dependencies' and not 'devDependencies' in your 'package.json file'. This is because Heroku prunes (removes) your 'devDependencies' once it completes its build process, leaving only the 'dependencies', to keep the app as lean as possible.
This causes errors if you've built your NodeJS app using ES6 modules and included the necessary dependencies under 'devDependencies' instead of 'dependencies', namely the '#babel/' family of dependencies.
Update
You should always build your NodeJS App before you deploy it so that you are always running the production build in the live environment which executes much faster with fewer resources.

Resources