laravel npm运行dev错误!代码ELIFECYCLE @开发脚本失败

时间:2018-11-24 05:00:25

标签: node.js laravel npm laravel-mix

我正在尝试运行npm run dev,但是失败

节点版本:11.2.0,npm版本:6.4.1,操作系统:windows10

它发出此错误:


> @ dev C:\xampp\htdocs\laravel\tutorial
> npm run development


> @ development C:\xampp\htdocs\laravel\tutorial
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 70% building 12/18 modules 6 active ...utorial\node_modules\axios\lib\axios.jsTypeError: dep.getResourceIdentifier is not a function
    at addDependency (C:\xampp\htdocs\laravel\tutorial\node_modules\webpack\lib\Compilation.js:690:30)
    at iterationOfArrayCallback (C:\xampp\htdocs\laravel\tutorial\node_modules\webpack\lib\Compilation.js:194:3)
    at addDependenciesBlock (C:\xampp\htdocs\laravel\tutorial\node_modules\webpack\lib\Compilation.js:712:5)
    at Compilation.processModuleDependencies (C:\xampp\htdocs\laravel\tutorial\node_modules\webpack\lib\Compilation.js:723:4)
    at afterBuild (C:\xampp\htdocs\laravel\tutorial\node_modules\webpack\lib\Compilation.js:855:15)
    at buildModule.err (C:\xampp\htdocs\laravel\tutorial\node_modules\webpack\lib\Compilation.js:899:11)
    at callback (C:\xampp\htdocs\laravel\tutorial\node_modules\webpack\lib\Compilation.js:628:5)
    at module.build.error (C:\xampp\htdocs\laravel\tutorial\node_modules\webpack\lib\Compilation.js:676:12)
    at handleParseResult (C:\xampp\htdocs\laravel\tutorial\node_modules\webpack\lib\NormalModule.js:441:12)
    at doBuild.err (C:\xampp\htdocs\laravel\tutorial\node_modules\webpack\lib\NormalModule.js:463:6)
    at runLoaders (C:\xampp\htdocs\laravel\tutorial\node_modules\webpack\lib\NormalModule.js:327:12)
    at C:\xampp\htdocs\laravel\tutorial\node_modules\loader-runner\lib\LoaderRunner.js:370:3
    at iterateNormalLoaders (C:\xampp\htdocs\laravel\tutorial\node_modules\loader-runner\lib\LoaderRunner.js:211:10)
    at Array. (C:\xampp\htdocs\laravel\tutorial\node_modules\loader-runner\lib\LoaderRunner.js:202:4)
    at Storage.finished (C:\xampp\htdocs\laravel\tutorial\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:43:16)
    at provider (C:\xampp\htdocs\laravel\tutorial\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:79:9)
    at C:\xampp\htdocs\laravel\tutorial\node_modules\graceful-fs\graceful-fs.js:90:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53: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`
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!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2018-11-24T04_26_39_857Z-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.

这是日志:


0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'dev' ]
2 info using npm@6.4.1
3 info using node@v11.2.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle @~predev: @
6 info lifecycle @~dev: @
7 verbose lifecycle @~dev: unsafe-perm in lifecycle true
8 verbose lifecycle @~dev: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\xampp\htdocs\laravel\tutorial\node_modules\.bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\User\bin;C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\android-sdk\platform-tools;C:\Gradle\gradle-4.7\bin;C:\WINDOWS\System32\OpenSSH;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\nodejs;C:\Users\User\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\User\AppData\Roaming\Composer\vendor\bin;C:\Users\User\AppData\Roaming\npm
9 verbose lifecycle @~dev: CWD: C:\xampp\htdocs\laravel\tutorial
10 silly lifecycle @~dev: Args: [ '/d /s /c', 'npm run development' ]
11 silly lifecycle @~dev: Returned: code: 1  signal: null
12 info lifecycle @~dev: Failed to exec dev script
13 verbose stack Error: @ dev: `npm run development`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:182:13)
13 verbose stack     at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:182:13)
13 verbose stack     at maybeClose (internal/child_process.js:978:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
14 verbose pkgid @
15 verbose cwd C:\xampp\htdocs\laravel\tutorial
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
18 verbose node v11.2.0
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error @ dev: `npm run development`
22 error Exit status 1
23 error Failed at the @ dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

我已经从各种网站(包括以下网站)中搜索并尝试了多种方式:

解决方案1)

  • 删除node_module文件夹或通过$ rm -rf node_modules删除
  • 删除package-lock.json
  • npm清除缓存--force
  • npm安装

解决方案2)

  • npm install -g跨环境

解决方案3)

  • npm缓存验证

解决方案4)

  • npm install webpack @ latest

解决方案5)

  • 在package.json中用'node'或'set'替换交叉环境
  • 或将dist放在package.json中的/ bin之前

解决方案6)

  • npm更新

我没有选择和解决方案。还有另一种解决方法吗?

p / s:我读到一些有关服务器内存不足的信息。与我的错误有关吗?

1 个答案:

答案 0 :(得分:0)

这是一种解决方法,不是实际的解决方法。解决方案是更改webpack版本。我的最新版本为4.26.0。显然,混合无法在v4上很好地工作。

  • npm i webpack@3.1.0

我从这里得到了解决方案:When running npm run dev getting this error dep.getResourceIdentifier is not a function #1610

我无法相信我花了超过10个小时的时间来解决此问题,却发现自己在网上发布答案后的几分钟-_-