我正在尝试运行 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 [email protected]
3 info using [email protected]
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)
解决方案2)
解决方案3)
解决方案4)
解决方案5)
解决方案6)
我没有选择和解决方案。还有其他方法可以解决这个问题吗?
p/s:我读到一些有关服务器内存耗尽或类似内容的内容。这和我的错误有什么关系吗?
这是一种解决方法,而不是实际的解决方案。解决方案是更改 webpack 版本。我有最新版本4.26.0。显然,mix 不适用于 v4。
我从这里得到了解决方案:运行 npm run dev 时收到此错误 dep.getResourceIdentifier 不是函数 #1610
不敢相信我花了超过 10 个小时试图解决这个问题,结果在我将其发布到网上几分钟后才找到答案 -_-
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"@tailwindcss/forms": "^0.4.0",
"alpinejs": "^3.4.2",
"autoprefixer": "^10.4.2",
"axios": "^0.21",
"bootstrap": "^4.6.0",
"jquery": "^3.5",
"laravel-mix": "^6.0.6",
"laravel-mix-merge-manifest": "^2.1.0",
"lodash": "^4.17.19",
"popper.js": "^1.16",
"postcss": "^8.4.6",
"sass": "^1.32.1",
"sass-loader": "^10.1.1",
"tailwindcss": "^3.0.18"
},
"dependencies": {
"codemirror": "^6.0.1"
}
}
将其粘贴到 package.json 中,然后删除 package-lock.json ,删除 node_modules 文件夹并运行 npm install 。然后是 npm run dev ,仅此而已......它 100% 对我有用。LARAVEL 8.x , 9.x ,6.x