I'm testing out the Mern Stack (Mongo Express React/Redux Node) and set it up with development with no issue. Now I'm trying to deploy to Heroku. I did a git push heroku master just like normal, but when I check out the website I see Heroku's Application Error. I added a MongoDB through Heroku, and changed my heroku config variables, so it uses that db (I think I did this correctly). So I check into logs:
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! mern-starter#1.0.0 start: `cross-env NODE_ENV=development nodemon index.js`
npm ERR! spawn ENOENT
A little way down:
> mern-starter#1.0.0 start /app
> cross-env NODE_ENV=development nodemon index.js
sh: 1: cross-env: not found
Further down:
npm ERR! Linux 3.13.0-79-generic
npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
npm ERR! node v5.10.0
npm ERR! npm v3.8.3
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! mern-starter#1.0.0 start: `cross-env NODE_ENV=development nodemon index.js`
npm ERR! syscall spawn
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the mern-starter#1.0.0 start script 'cross-env NODE_ENV=development nodemon index.js'.
So I don't know as much about the back end, but it appears to be running the development script in package.json:
"scripts": {
"test": "mocha shared/tests/*.spec.js --compilers js:babel-register",
"test:server": "cross-env NODE_ENV=test PORT=8080 MONGO_URL=mongodb://localhost:27017/mern-test mocha --compilers js:babel-register --recursive server/tests/**/*.spec.js",
"start": "cross-env NODE_ENV=development nodemon index.js",
"start:prod": "cross-env NODE_ENV=production node index.js",
"bs": "npm run clean && npm run build && npm run start:prod",
"minify": "cleancss -o static/css/app.min.css static/css/app.css",
"build": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js && npm run minify",
"clean": "rimraf static/dist",
"slate": "rimraf node_modules && npm install",
"lint": "eslint client server shared"
}
So how can I get this to work?
EDIT:
"devDependencies": {
"babel-eslint": "^5.0.0-beta6",
"babel-loader": "^6.2.1",
"babel-plugin-react-transform": "^2.0.0",
"babel-plugin-transform-react-constant-elements": "6.5.0",
"babel-plugin-transform-react-inline-elements": "6.6.5",
"babel-plugin-transform-react-remove-prop-types": "0.2.4",
"babel-polyfill": "^6.3.14",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-react-hmre": "^1.1.0",
"babel-register": "^6.7.2",
"chai": "^3.5.0",
"clean-css": "^3.4.9",
"cross-env": "^1.0.7",
"css-loader": "^0.23.1",
"css-modules-require-hook": "^2.1.0",
"deep-freeze": "0.0.1",
"eslint": "^1.10.3",
"eslint-config-airbnb": "^4.0.0",
"eslint-plugin-react": "^3.16.1",
"expect": "^1.13.4",
"expect-jsx": "^2.2.2",
"extract-text-webpack-plugin": "^1.0.1",
"mocha": "^2.4.5",
"nodemon": "^1.9.1",
"pre-commit": "^1.1.2",
"react-addons-test-utils": "^0.14.7",
"react-transform-hmr": "^1.0.1",
"redux-devtools": "^3.1.1",
"redux-devtools-dock-monitor": "^1.1.0",
"redux-devtools-log-monitor": "^1.0.4",
"rimraf": "^2.5.1",
"style-loader": "^0.13.0",
"supertest": "^1.1.0",
"webpack": "^1.12.12",
"webpack-dev-middleware": "^1.5.1",
"webpack-hot-middleware": "^2.6.4"
},
I wrote about it here: https://hashnode.com/post/deploying-mern-to-heroku-success-cio7sc1py013nis531rg3lfmz
The reason is because herokou does not know about your devDependencies tree, only your regular dependencies get pushed.
A quick fix is to copy all of your devDependencies to your dependencies
You will also have to remove the following from the .gitignore file:
public/*
static/dist
static/css/app.min.css
There are a couple other steps I outlined in the article, but those are the primary reasons it won't work without some extra configurations.
Related
When I try to install Vuex using NPM commands, it gives this error.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined#undefined
npm ERR! Found: vue#2.6.14
npm ERR! node_modules/vue
npm ERR! dev vue#"^2.6.12" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue#"^3.0.2" from vuex#4.0.2
npm ERR! node_modules/vuex
npm ERR! vuex#"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/viraj/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/viraj/.npm/_logs/2022-06-23T16_10_55_210Z-debug-0.log
I tried using npm install vuex --save and npm install vuex#next --save as well. But both of them not work for me. Why is this happen? And I will be really appreciate if anyone can give some solution for this.
Note : I'm using Vue js with my Laravel project. Here is my package.json file for further refrence.
{
"private": true,
"scripts": {
"dev": "npm run development -- --watch",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production",
"lint": "eslint resources/js"
},
"devDependencies": {
"#popperjs/core": "^2.10.2",
"axios": "^0.21.4",
"bootstrap": "^5.1.3",
"deepmerge": "^4.2.2",
"eslint": "^8.16.0",
"eslint-plugin-vue": "^9.1.0",
"laravel-mix": "^6.0.44",
"lodash": "^4.17.19",
"postcss": "^8.1.14",
"resolve-url-loader": "^3.1.2",
"sass": "^1.32.13",
"sass-loader": "^11.1.1",
"vue": "^2.6.12",
"vue-loader": "^15.9.8",
"vue-template-compiler": "^2.6.12"
},
"dependencies": {
"vue-feather-icons": "^5.1.0",
"vuetify": "^2.6.6"
}
}
You have vue2 so you need vuex3 not 4
npm install vuex#3.4.0 --save
I was creating a new laravel project and while installing the npm this error occurred
Command that I ran was npm install
- Laravel Framework 8.6.0
- Node Version:- 8.10.0
Error:-
npm WARN deprecated popper.js#1.16.1: You can find the new Popper v2 at #popperjs/core, this package is dedicated to the legacy v1
loadDevDep:vue-template-c - |################---------------------------------|
WARN engine cross-env#7.0.2: wanted: {"node":">=10.14","npm":">=6","yarn":">=1"}npm WARN deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm ERR! Linux 5.4.0-48-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code EMISSINGARG
npm ERR! typeerror Error: Missing required argument #1
npm ERR! typeerror at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
npm ERR! typeerror at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
npm ERR! typeerror at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
npm ERR! typeerror at /usr/share/npm/lib/install/deps.js:457:7
npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror at /usr/share/npm/lib/fetch-package-metadata.js:37:12
npm ERR! typeerror at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)
npm ERR! typeerror at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)
npm ERR! typeerror at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)
npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror <http://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /home/kabir/.config/composer/vendor/laravel/installer/bin/White0.1/npm-debug.log
package.json:-
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.19",
"bootstrap": "^4.0.0",
"cross-env": "^7.0",
"jquery": "^3.2",
"laravel-mix": "^5.0.1",
"lodash": "^4.17.19",
"popper.js": "^1.12",
"resolve-url-loader": "^2.3.1",
"sass": "^1.20.1",
"sass-loader": "^8.0.0",
"vue": "^2.5.17",
"vue-template-compiler": "^2.6.10"
}
}
I don't have any idea what's wrong, Please help. I hope this information is enough. do ask if more is needed.
I believe this is because you're using an older version of node & NPM that one (or more) of your dependencies doesn't support.
Using the same versions as you (Node#8.10.0 and NPM#3.5.2) I also get an error when running npm install.
With more recent versions (Node#12.15.0 and NPM#6.13.4) your package.json installs without a problem.
i installed the npm using command-line successfully but when i use to run npm run dev it shows me some errors!
i have tried to replace the code of packages.json provided on github and reinstall npm but still getting same error.
npm run dev
C:\wamp64\www\shopping>npm run dev
'CALL "C:\Program Files\nodejs\\node.exe"
"C:\Program Files\nodejs\\node_modules\npm\bin\npm-cli.js" prefix -g' is
not recognized as an internal or external command,operable program or batch file.
# dev C:\wamp64\www\shopping
npm run development
npm ERR! file C:\WINDOWS\system32\cmd.exe;C:\Program Files\Java\jdk-10.0.2\bin;
npm ERR! path C:\WINDOWS\system32\cmd.exe;C:\Program Files\Java\jdk-10.0.2\bin;
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn C:\WINDOWS\system32\cmd.exe;C:\Program Files\Java\jdk-10.0.2\bin;
npm ERR! # dev: `npm run development`
npm ERR! spawn C:\WINDOWS\system32\cmd.exe;C:\Program Files\Java\jdk-10.0.2\bin;
ENOENT
npm ERR!
npm ERR! Failed at the # dev 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\hp\AppData\Roaming\npm-cache\_logs\2019-08-28T19_22_32_311Z-debug.log
package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.18",
"bootstrap": "^4.1.0",
"cross-env": "^5.2.0",
"jquery": "^3.2",
"laravel-mix": "^4.0.7",
"lodash": "^4.17.5",
"popper.js": "^1.12",
"resolve-url-loader": "^2.3.1",
"sass": "^1.15.2",
"sass-loader": "^7.1.0",
"vue": "^2.5.17"
}
}
I have created a simple app with Spring Boot and Angular 4. I tried to run a script which will pack every (npm run build) file from frontend file to the src/main/resources/static file. But I am getting an error which is:
npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.9.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! tasks#0.0.0 postbuild: `npm run deploy`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tasks#0.0.0 postbuild script 'npm run deploy'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the tasks package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run deploy
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs tasks
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls tasks
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Michał\IdeaProjects\spring-angular2-tasks-master\Spring with Angular 4\src\main\frontend\npm-debug.log
My package.json file looks:
{
"name": "tasks",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy-conf.json",
"build": "ng build -prod",
"postbuild": "npm run deploy",
"predeploy": "rimraf ../resources/static/ && mkdirp ../resources/static",
"deploy": "copyfiles -f dist/** ../resources/static",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"#angular/common": "^4.1.3",
"#angular/compiler": "^4.1.3",
"#angular/core": "^4.1.3",
"#angular/forms": "^4.1.3",
"#angular/http": "^4.1.3",
"#angular/platform-browser": "^4.1.3",
"#angular/platform-browser-dynamic": "^4.1.3",
"#angular/router": "^4.1.3",
"bootstrap": "^3.3.7",
"copyfiles": "^1.2.0",
"core-js": "^2.4.1",
"mkdirp": "^0.5.1",
"moment": "^2.18.1",
"rimraf": "^2.6.1",
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"zone.js": "^0.8.11"
},
"devDependencies": {
"#angular/cli": "^1.0.0",
"#angular/compiler-cli": "^4.1.3",
"#types/jasmine": "2.5.47",
"#types/node": "^7.0.22",
"codelyzer": "~3.0.1",
"jasmine-core": "2.6.2",
"jasmine-spec-reporter": "4.1.0",
"karma": "1.7.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.6.0",
"protractor": "~5.1.2",
"ts-node": "3.0.4",
"tslint": "^5.3.2",
"typescript": "~2.3.3"
},
"description": "This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.2.6.",
"main": "karma.conf.js",
"author": ""
}
What am I doing wrong?
UPDATE:
After running npm run deploy I have:
> tasks#0.0.0 predeploy C:\Users\Michał\IdeaProjects\spring-angular2-tasks-master\Spring with Angular 4\src\main\frontend
> rimraf ../resources/static/ && mkdirp ../resources/static
> tasks#0.0.0 deploy C:\Users\Michał\IdeaProjects\spring-angular2-tasks-master\Spring with Angular 4\src\main\frontend
> copyfiles -f dist/** ../resources/static
'copyfiles' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "deploy"
npm ERR! node v6.9.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! tasks#0.0.0 deploy: `copyfiles -f dist/** ../resources/static`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tasks#0.0.0 deploy script 'copyfiles -f dist/** ../resources/static'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the tasks package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! copyfiles -f dist/** ../resources/static
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs tasks
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls tasks
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Michał\IdeaProjects\spring-angular2-tasks-master\Spring with Angular 4\src\main\frontend\npm-debug.log
Solve it by npm install copyfiles -g
I have been trying to set up Laravel Mix in my project and followed the install guide on the Laravel website however keep getting errors.
My package.json
{
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack --progress --hide-modules",
"watch": "cross-env NODE_ENV=development webpack --watch --progress --hide-modules",
"hot": "cross-env NODE_ENV=development webpack-dev-server --inline --hot",
"production": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"devDependencies": {
"axios": "^0.15.2",
"bootstrap-sass": "^3.3.7",
"jquery": "^3.1.0",
"laravel-mix": "^0.4.0",
"lodash": "^4.16.2",
"vue": "^2.0.1"
},
"name": "Code",
"version": "1.0.0",
"main": "webpack.mix.js",
"directories": {
"test": "tests"
},
"dependencies": {
"ansi-regex": "^2.1.1",
"ansi-styles": "^2.2.1",
"axios": "^0.15.3",
"babel-core": "^6.24.1",
"babel-code-frame": "^6.22.0",
"babel-generator": "^6.24.1",
"babel-messages": "^6.23.0",
"babel-helpers": "^6.24.1",
"babel-register": "^6.24.1",
"babel-template": "^6.24.1",
"babylon": "^6.17.0",
"balanced-match": "^0.4.2",
"babel-runtime": "^6.23.0",
"babel-types": "^6.24.1",
"babel-traverse": "^6.24.1",
"brace-expansion": "^1.1.7",
"bootstrap-sass": "^3.3.7",
"chalk": "^1.1.3",
"convert-source-map": "^1.5.0",
"concat-map": "^0.0.1",
"core-js": "^2.4.1",
"cross-env": "^3.2.4",
"detect-indent": "^4.0.0",
"esutils": "^2.0.2",
"escape-string-regexp": "^1.0.5",
"follow-redirects": "^1.0.0",
"globals": "^9.17.0",
"has-ansi": "^2.0.0",
"home-or-tmp": "^2.0.0",
"is-finite": "^1.0.2",
"invariant": "^2.2.2",
"json5": "^0.5.1",
"js-tokens": "^3.0.1",
"jquery": "^3.2.1",
"jsesc": "^1.3.0",
"laravel-mix": "^0.4.0",
"lodash": "^4.17.4",
"loose-envify": "^1.3.1",
"mkdirp": "^0.5.1",
"minimatch": "^3.0.3",
"minimist": "^0.0.8",
"number-is-nan": "^1.0.1",
"os-homedir": "^1.0.2",
"os-tmpdir": "^1.0.2",
"path-is-absolute": "^1.0.1",
"private": "^0.1.7",
"regenerator-runtime": "^0.10.3",
"repeating": "^2.0.1",
"slash": "^1.0.0",
"source-map": "^0.5.6",
"source-map-support": "^0.4.14",
"strip-ansi": "^3.0.1",
"trim-right": "^1.0.1",
"to-fast-properties": "^1.0.2",
"vue": "^2.3.0"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}
The error I am getting when I run any npm run command.
> Code#1.0.0 dev /home/vagrant/Code
> cross-env NODE_ENV=development webpack --progress --hide-modules
sh: 1: cross-env: not found
npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v7.8.0
npm ERR! npm v4.2.0
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! Code#1.0.0 dev: `cross-env NODE_ENV=development webpack --progress --hide-modules`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the Code#1.0.0 dev script 'cross-env NODE_ENV=development webpack --progress --hide-modules'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the Code package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! cross-env NODE_ENV=development webpack --progress --hide-modules
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs Code
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls Code
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/vagrant/.npm/_logs/2017-04-28T17_24_11_458Z-debug.log
I am running my project on a Vagrant box, and I am running Laravel version 5.4.
You need to make cross-env working globally instead of having it in the project.
run
$ sudo npm install --global cross-env
--- update ---
But, my advice is to avoid executing npm run ... on the guest homestead, because it is very slow and because there is no benefit in it.
No matter where you build the assets they are going to be executed in the browser. So you better install npm on your host computer and build the assets there.
First check if cross-env module is installed. If not, run:
npm install cross-env
After that you need to go to the node_modules folder.
Then find cross-env folder. Go inside and find cross-env.js.
In my case it was node_modules/cross-env/dist/bin/cross-env.js
You need to change path to cross-env.js in scripts section in your package.json file.
{
"private": true,
"scripts": {
"dev": "node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
........
}
Run:
npm install
Then try again.
If the solutions above didn't work, refresh node_modules using
rm -rf node_modules && npm install
this worked for me
The fast solution is to run:
npm clean-install
that sould fix the laravel mix error.
There are couple of ways to solve this error.
Delete node_modules folder then do npm install again.
if it doesn't solve then:
You can install as dev dependency by firing
npm install --save-dev cross-env
if it doesn't solve then:
Install cross-env globally as npm install --g cross-env
It will install it in \Users\Roaming\npm modules. Then I suggest you can close your shell and open it again & fire the command.
if it doesn't solve then:
- in Package.json you can use like:
node node_modules/dist/bin/cross-env cross-env ...
Sometimes deleting the /node_modules and running
npm install
will solve issues like this one.
You do need to check if cross-env module is installed. If not, run:
npm install cross-env
But you need it to be recognized as a "command". Patching the path as proposed by the accepted answer (or is it?) led me further, but still gave me an error.
The solution for me was to reload vagrant "vagrant reload --provision", and reset my ssh / putty session.
If you are just desperate of fixing this error like my case, just remove cross-env from you package.json and run laravel mix without it ..
I had to clone repository in a new folder.
Wasn't able to identify which local file/setting caused the error.