问题
我陷入了一个循环,其中运行npm run watch
表示找不到cross-spawn
。
> @ watch /Users/donnie/Github/laravel_project
> npm run development -- --watch
> @ development /Users/donnie/Github/laravel_project
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"
module.js:549
throw err;
^
Error: Cannot find module 'cross-spawn'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/donnie/.yarn-cache/npm-cross-env-5.2.0/dist/index.js:5:19)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
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 "--watch"`
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/donnie/.npm/_logs/2019-01-22T21_57_39_199Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ watch: `npm run development -- --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ watch 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/donnie/.npm/_logs/2019-01-22T21_57_39_227Z-debug.log
我运行成功的npm i --D cross-spawn
,然后再次运行npm run watch
。它说还必须安装一些依赖关系(这很奇怪,因为我做的第一件事是npm install
。)无论如何,它最终提供了以下反馈:
Okay, done. The following packages have been installed and saved to your package.json dependencies list:
- vue-template-compiler
- sass-loader@7.*
- sass
- resolve-url-loader@2.3.1
Finished. Please run Mix again.
很酷。所以我再次运行npm run watch
,我们又回到了cross-spawn
问题。
我尝试删除/node_modules
并重新开始。没有运气。
package.json
{
"devDependencies": {
"axios": "^0.18",
"bootstrap": "^4.0.0",
"cross-env": "^5.1",
"cross-spawn": "^6.0.5"
"false": "^0.0.4",
"jquery": "^3.2",
"laravel-mix": "^4.0.7",
"lodash": "^4.17.5",
"popper.js": "^1.12",
"resolve-url-loader": "2.3.1",
"sass": "^1.16.1",
"sass-loader": "7.*",
"vue": "^2.5.17",
"vue-template-compiler": "^2.5.22"
},
"dependencies": {}
}
环境
答案 0 :(得分:0)
先运行npm rebuild
,然后运行npm install
应该可以解决此问题。现在,运行npm run dev
应该可以正常运行。
我认为此问题与文件权限错误有关,npm rebuild
似乎可以解决问题。