为什么我不能运行Npm run dev?

时间:2020-02-26 17:14:53

标签: npm npm-install laravel-mix

您可以帮我解决这个问题,因为我在为Laravel Mix运行 npm run dev 时遇到问题。我按了以下链接,但仍然存在错误。我的操作系统有问题吗?我试图删除node_modules,运行npm install --global cross-env。并再次运行NPM安装。

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

https://github.com/JeffreyWay/laravel-mix/issues/478

运行npm run dev时总是出现的错误:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/baloghdominik/.npm/_logs/2020-02-26T17_05_54_290Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/baloghdominik/.npm/_logs/2020-02-26T17_05_54_315Z-debug.log

4 个答案:

答案 0 :(得分:1)

首次运行

npm install cross-env

npm install 

然后运行

npm run dev

答案 1 :(得分:0)

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

基本上删除 node_modules 文件夹和 package-lock.json 文件,清除缓存并进行 npm 安装。为我工作。

答案 2 :(得分:0)

简单步骤:

  1. npm 缓存清除 --force
  2. 删除 node_modules 和 package-lock.json
  3. npm 安装
  4. npm run dev
  5. 谢谢我,一切都会好的

快乐编码!

答案 3 :(得分:0)

就我而言,我有旧版本的 node.js 所以我刚刚安装了我需要的版本:

sudo npm install n -g

sudo n stable

或者可以尝试使用最新的:

sudo n latest