Laravel 5.5 + Vue.js 2.x项目没有在npm run dev上工作

时间:2017-09-04 08:23:46

标签: laravel npm webpack vuejs2 laravel-5.5

当我为Laravel 5.5 + Vue.js 2.x创建新项目时,我遇到了问题。这是我运行之后的消息。

npm install 
npm run dev


> @ dev /Volumes/Work/Work/Vue/CRUD
> npm run development


> @ development /Volumes/Work/Work/Vue/CRUD
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 95% emitting                                                                         

 DONE  Compiled successfully in 2830ms                                                                                         6:01:15 PM

internal/child_process.js:325
    throw errnoException(err, 'spawn');
    ^

Error: spawn EACCES
    at _errnoException (util.js:1041:11)
    at ChildProcess.spawn (internal/child_process.js:325:11)
    at exports.spawn (child_process.js:493:9)
    at Object.exports.execFile (child_process.js:208:15)
    at Object.module.exports.fileCommand (/Volumes/Work/Work/Vue/CRUD/node_modules/node-notifier/lib/utils.js:53:13)
    at NotificationCenter.notify (/Volumes/Work/Work/Vue/CRUD/node_modules/node-notifier/notifiers/notificationcenter.js:66:11)
    at module.exports.WebpackNotifierPlugin.compilationDone (/Volumes/Work/Work/Vue/CRUD/node_modules/webpack-notifier/index.js:62:18)
    at Compiler.applyPlugins (/Volumes/Work/Work/Vue/CRUD/node_modules/tapable/lib/Tapable.js:61:14)
    at emitRecords.err (/Volumes/Work/Work/Vue/CRUD/node_modules/webpack/lib/Compiler.js:268:11)
    at Compiler.emitRecords (/Volumes/Work/Work/Vue/CRUD/node_modules/webpack/lib/Compiler.js:375:38)
    at emitAssets.err (/Volumes/Work/Work/Vue/CRUD/node_modules/webpack/lib/Compiler.js:262:10)
    at applyPluginsAsyncSeries1.err (/Volumes/Work/Work/Vue/CRUD/node_modules/webpack/lib/Compiler.js:368:12)
    at next (/Volumes/Work/Work/Vue/CRUD/node_modules/tapable/lib/Tapable.js:218:11)
    at Compiler.compiler.plugin (/Volumes/Work/Work/Vue/CRUD/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
    at Compiler.applyPluginsAsyncSeries1 (/Volumes/Work/Work/Vue/CRUD/node_modules/tapable/lib/Tapable.js:222:13)
    at Compiler.afterEmit (/Volumes/Work/Work/Vue/CRUD/node_modules/webpack/lib/Compiler.js:365:9)
    at require.forEach.err (/Volumes/Work/Work/Vue/CRUD/node_modules/webpack/lib/Compiler.js:354:15)
    at /Volumes/Work/Work/Vue/CRUD/node_modules/async/dist/async.js:421:16
    at iteratorCallback (/Volumes/Work/Work/Vue/CRUD/node_modules/async/dist/async.js:998:13)
    at /Volumes/Work/Work/Vue/CRUD/node_modules/async/dist/async.js:906:16
    at /Volumes/Work/Work/Vue/CRUD/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:135:15)
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/paladin2/.npm/_logs/2017-09-04T08_01_15_242Z-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/paladin2/.npm/_logs/2017-09-04T08_01_15_321Z-debug.log

过去有没有人遇到同样的问题?

5 个答案:

答案 0 :(得分:1)

如果npm update不起作用,请尝试通过命令手动安装webpack。

npm install –save-dev npm-install-webpack-plugin

答案 1 :(得分:0)

今天早上我遇到了同样的问题,我记得我最近更新了我的npm版本。 即使我创建了一个新项目并且运行了 npm install && npm run dev 我遇到了同样的问题。

我的临时解决方案是降级npm: npm install -g npm@5.3

如果我现在运行npm run dev一切正常。

答案 2 :(得分:0)

我认为该问题导致了该文件夹的许可。

当我像这样设置文件夹权限时,一切都在我的电脑上正常工作。

chmod -R 765 [foldername]

感谢。

答案 3 :(得分:0)

为您的用户提供node_modules的执行权限可以解决问题:chmod -R u+x node_modules/

答案 4 :(得分:0)

我安装时没有 laragon 虚拟主机。出现与未找到cross-env相同的错误。 经过数小时的研究,我找到了解决方案。这是我的做法:

  1. npm install cross-env -g
  2. npm update
  3. npm install --save

之后npm run devnpm run build

轰! Laravel Mix构建成功。它正在工作.....