Laravel 5.4 ‘cross-env’ Is Not Recognized as an Internal or External Command

前端 未结 16 1163
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 17:04

I\'m trying to run npm run dev for Laravel Mix and I get this error:

> @ dev D:\\projects\\ptcs
> cross-env NODE_ENV=development webpack -         


        
16条回答
  •  我在风中等你
    2020-11-29 17:59

    This worked for me (on Windows 10):

    1. Add the following lines into your scripts in the package.json file:

      "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"
      
    2. Make your devDependencies looks something like this:

      "devDependencies": {
          "axios": "^0.18",
          "bootstrap": "^4.0.0",
          "popper.js": "^1.12",
          "cross-env": "^5.1",
          "jquery": "^3.2",
          "laravel-mix": "^2.0",
          "lodash": "^4.17.4",
          "vue": "^2.5.7"
      }
      
    3. Remove node_modules folder

    4. Run npm install
    5. Run npm run dev

提交回复
热议问题