vue项目启动报错dep.getResourceIdentifier is not a function
拿到一个很旧的前端项目,安装依赖后报错:
TypeError: dep.getResourceIdentifier is not a function
at addDependency (E:\project\xxx\node_modules\@vue\cli-service\node_modules\webpack\lib\Compilation.js:796:30)
at iterationOfArrayCallback (E:\project\xxx\node_modules\@vue\cli-service\node_modules\webpack\lib\Compilation.js:208:3)
at addDependenciesBlock (E:\project\xxx\node_modules\@vue\cli-service\node_modules\webpack\lib\Compilation.js:816:5)
at Compilation.processModuleDependencies (E:\project\xxx\node_modules\@vue\cli-service\node_modules\webpack\lib\Compilation.js:827:4)
at afterBuild (E:\project\xxx\node_modules\@vue\cli-service\node_modules\webpack\lib\Compilation.js:954:15)
at E:\project\xxx\node_modules\@vue\cli-service\node_modules\webpack\lib\Compilation.js:998:11
at callback (E:\project\xxx\node_modules\@vue\cli-service\node_modules\webpack\lib\Compilation.js:734:5)
at E:\project\xxx\node_modules\@vue\cli-service\node_modules\webpack\lib\Compilation.js:782:12
at handleParseResult (E:\project\xxx\node_modules\@vue\cli-service\node_modules\webpack\lib\NormalModule.js:478:12)
at E:\project\xxx\node_modules\@vue\cli-service\node_modules\webpack\lib\NormalModule.js:500:6
at E:\project\xxx\node_modules\@vue\cli-service\node_modules\webpack\lib\NormalModule.js:358:12
at E:\project\xxx\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (E:\project\xxx\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at iterateNormalLoaders (E:\project\xxx\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
at E:\project\xxx\node_modules\loader-runner\lib\LoaderRunner.js:236:3
at context.callback (E:\project\xxx\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
at E:\project\xxx\node_modules\cache-loader\dist\index.js:147:7
at E:\project\xxx\node_modules\graceful-fs\graceful-fs.js:61:14
at FSReqCallback.oncomplete (fs.js:180:23)
参考网络上的说法,降低了webpack版本:
npm uninstall webpack
npm install webpack@^3.11.0
但无效。
于是找了负责这个项目代码的同事,他让我替换了package-lock.json,再重新npm install,问题解决。
观察对比了自动生成和同事给的两个package-lock.json文件,主要是babel相关的依赖降低了版本,很多很多个,如果自己来解决估计要费大劲。
此类问题,一般是因为框架太旧,使用的依赖不适配。
而解决办法,最快速的还是,解铃还须系铃人(