DEV Community

Shruthi-Gowda
Shruthi-Gowda

Posted on

I am trying to deploy static react app to heroku, but i get error like “cross-env: not found” any help is appreciated

Error occurs while deploying. locally everything works fine.

I am aware that cross-env is a development dependency. Heroku, by default, only installs production dependencies.

below is the package.json and error log. Please let me know how to solve it.

Package.json

{
"name": "project",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "cross-env NODE_ENV=development webpack serve",
"build": "cross-env NODE_ENV=production webpack",
"test": "jest"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel /core": "^7.14.6",
"@babel /preset-env": "^7.14.5",
"@babel /preset-react": "^7.14.5",
"@wojtekmaj /enzyme-adapter-react-17": "^0.6.2",
"babel-jest": "^27.0.2",
"babel-loader": "^8.2.2",
"cross-env": "^7.0.3",
"css-loader": "^5.2.6",
"enzyme": "^3.11.0",
"file-loader": "^6.2.0",
"html-loader": "^2.1.2",
"html-webpack-plugin": "^5.3.1",
"jest": "^27.0.4",
"mini-css-extract-plugin": "^1.6.0",
"node-sass": "^6.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"sass-loader": "^12.1.0",
"webpack": "^5.39.1",
"webpack-cli": "^4.7.2",
"webpack-dev-server": "^3.11.2"
}
}

Error log:

,,,
2021-06-21T14:58:17.290672+00:00 app[web.1]: > project@1.0.0 start /app
2021-06-21T14:58:17.290673+00:00 app[web.1]: > cross-env NODE_ENV=development webpack serve
2021-06-21T14:58:17.290673+00:00 app[web.1]:
2021-06-21T14:58:17.296829+00:00 app[web.1]: sh: 1: cross-env: not found
2021-06-21T14:58:17.316513+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-06-21T14:58:17.317015+00:00 app[web.1]: npm ERR! syscall spawn
2021-06-21T14:58:17.317223+00:00 app[web.1]: npm ERR! file sh
2021-06-21T14:58:17.317548+00:00 app[web.1]: npm ERR! errno ENOENT
2021-06-21T14:58:17.324706+00:00 app[web.1]: npm ERR! project@1.0.0 start: cross-env NODE_ENV=development webpack serve
2021-06-21T14:58:17.324883+00:00 app[web.1]: npm ERR! spawn ENOENT
2021-06-21T14:58:17.325099+00:00 app[web.1]: npm ERR!
2021-06-21T14:58:17.327281+00:00 app[web.1]: npm ERR! Failed at the project@1.0.0 start script.

Top comments (1)

Collapse
 
harshmangalam profile image
Harsh Mangalam

if you will add cross-env in dev dependencies then heroku will not install it and if it will not install how heroku will execute build and start scripts from package.json