'cross-env' is not recognized as an internal or external command,

后端 未结 4 956
难免孤独
难免孤独 2021-02-01 05:24

Guys can you please help me on this I have trouble run npm run dev for my Laravel Mix. I followed links below but still error exist. Do i have a problem on my OS? I tried to rem

相关标签:
4条回答
  • 2021-02-01 05:57

    First, run:

    rm -rf node_modules
    rm package-lock.json yarn.lock
    npm cache clear --force
    

    Then run the command

    npm install cross-env
    
    npm install 
    

    and then you can also run

    npm run dev
    
    0 讨论(0)
  • 2021-02-01 05:57

    Did you try specifying the path to cross-env as suggested by dwoodward on the Github issue you linked? This goes in your package.json file:

    "dev": "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": "node node_modules/cross-env/dist/bin/cross-env.js 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": "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",
    "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"
    

    This may have changed in more recent versions of Laravel but the gist is that you should change cross-env to node_modules/cross-env/dist/bin/cross-env.js.

    0 讨论(0)
  • 2021-02-01 06:08

    Try Add the npm bin directory to your system path e.g C:\Users\DELL\AppData\Local\Yarn\bin

    0 讨论(0)
  • 2021-02-01 06:10

    I had the same issue. I resolved it by uninstalling node and then running the following command:

    npm install -d
    
    0 讨论(0)
提交回复
热议问题