"cross-env" is not recognized as an internal or external command, program or batch file executable

0

I am trying to execute the command: npm run watch to compile the files in laravel 5.6. I'm using laragon that includes Node js 8.9.

This is the error script:

$ npm run watch

> @ watch C:\laragon\www\learning
> npm run development -- --watch


> @ development C:\laragon\www\learning
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"

"cross-env" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ 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 ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Juanzu\AppData\Roaming\npm-cache\_logs18-11-21T22_07_58_504Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ watch: 'npm run development -- --watch'
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Juanzu\AppData\Roaming\npm-cache\_logs18-11-21T22_07_58_582Z-debug.log

So I have my file 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.0.0",
        "cross-env": "^5.1",
        "jquery": "^3.2",
        "laravel-mix": "^2.0",
        "lodash": "^4.17.5",
        "popper.js": "^1.12",
        "vue": "^2.5.7"
    }

}
    
asked by Juanzu 21.11.2018 в 23:15
source

2 answers

1

Try installing cross-env as a global module:

npm uninstall cross-env

Delete the node_modules directory and make sure that the "cross-env": "^5.1", line is no longer in the package.json file.

npm install --global cross-env
npm install --no-bin-links

And try again:

npm run watch
    
answered by 21.11.2018 в 23:55
0

Be sure to run npm install before running npm run watch or similar. You must have the folder "/ node_modules" and if you enter you should leave all the packages that are installed (you can see it in /package.json)

    
answered by 15.01.2019 в 15:57