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

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

    Delete the node_modules folder

    Then you should run the commands:

    npm install --no-bin-links
    
    npm run dev
    

    It's worked on my Laravel 5.5 and Windows.

    0 讨论(0)
  • 2020-11-29 17:44

    Simply try running npm install / yarn etc first before running npm start / yarn start as @only4 mentioned, if you see this problem, as it means your .env is not in sync with your package.json, i.e. you installed a package but not quite configured it or other way around

    0 讨论(0)
  • 2020-11-29 17:45

    You need to make cross-env working globally instead of having it in the project.

    1) remove node_modules folder

    2) run

    npm install --global cross-env

    3) remove "cross-env": "^5.0.1", from package.json file devDependencies section. Actually, you can skip this step and keep package.json intact. If you prefer.

    4) run

    npm install --no-bin-links

    5) run

    npm run dev

    and see it working

    P.S Tested on Windows 10 with Laravel-5.4

    P.P.S Windows 10 with Laravel-5.6 does not have this problem, thus updating is an alternative solution.

    0 讨论(0)
  • 2020-11-29 17:47

    You are getting the error because you might not have run the command npm install first.

    i.e. First, run npm install and then npm run dev

    0 讨论(0)
  • 2020-11-29 17:48

    Your error states that cross-env is not installed.

    'cross-env' is not recognized as an internal or external command, operable program or batch file.
    

    You just need to run

    npm install cross-env
    
    0 讨论(0)
  • 2020-11-29 17:51

    The following worked for Laravel 7.x (and should probably work for any other version as well given the nature of the issue).

    npm uninstall --save-dev cross-env
    npm install -g cross-env
    

    Just moving cross-env from being a local devDependency to a globally available package.

    0 讨论(0)
提交回复
热议问题