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

前端 未结 16 1166
被撕碎了的回忆
被撕碎了的回忆 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 18:04

    Before try running npm run dev please run npm install --no-bin-links in the project directory, this will install all required packages. Also check this link for compiling instruction. https://laravel.com/docs/5.4/mix

    Also double check in your conf file, wherever you find something like this

    (something)/cross-env/bin/(something)

    change it to

    (something)/cross-env/dist/bin/(something)

    If you are using homestead, in package.json paste this

    {
      "private": true,
      "scripts": {
        "dev": "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 NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch-poll": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "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",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
      },
      "devDependencies": {
        "axios": "^0.15.3",
        "bootstrap-sass": "^3.3.7",
        "cross-env": "^3.2.3",
        "jquery": "^3.1.1",
        "laravel-mix": "^0.8.1",
        "lodash": "^4.17.4",
        "vue": "^2.1.10"
      }
    }
    

    Also check this link https://github.com/JeffreyWay/laravel-mix/issues/478

提交回复
热议问题