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

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

    0 讨论(0)
  • I think this log entry Local package.json exists, but node_modules missing, did you mean to install? has gave me the solution.

    npm install && npm run dev
    
    0 讨论(0)
  • 2020-11-29 18:07

    I real all the solution but there is not a standard solution...

    JUST REMOVE NODEJS AND INSTALL THE LATEST VERSION OF NODEJS

    instead of many bad shortcut solutions.

    0 讨论(0)
  • 2020-11-29 18:09

    According to this issue comment, editing cross-env path will fix the problem. Change cross-env to node node_modules/cross-env/dist/bin/cross-env.js in package.json like this:

        "dev": "npm run development",
        "development": "node 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 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",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "node node_modules/cross-env/dist/bin/cross-env.js 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": "node 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"
    
    0 讨论(0)
提交回复
热议问题