Error: Cannot find module ‘vue-l
2020-10-24 本文已影响0人
seaflyj
前段时间接到一个朋友帮助,在启动vue3.0项目时候一直报错,网上搜了一堆没有解决问题,究其原因在于环境的配置;
先说一下遇到的问题:
拿到项目直接cnpm install,运行命令npm run serve报错:Cannot find module ‘vue-loader-v16/package.json‘
INFO Starting development server...
ERROR Error: Cannot find module 'vue-loader-v16/package.json'
Error: Cannot find module 'vue-loader-v16/package.json'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:613:15)
at Function.Module._load (internal/modules/cjs/loader.js:539:25)
at Module.require (internal/modules/cjs/loader.js:667:17)
at require (internal/modules/cjs/helpers.js:20:18)
at api.chainWebpack.webpackConfig (/home/riyad/Desktop/todo_wedevs/todo/node_modules/@vue/cli-service/lib/config/base.js:114:23)
at webpackChainFns.forEach.fn (/home/riyad/Desktop/todo_wedevs/todo/node_modules/@vue/cli-service/lib/Service.js:236:40)
at Array.forEach (<anonymous>)
at Service.resolveChainableWebpackConfig (/home/riyad/Desktop/todo_wedevs/todo/node_modules/@vue/cli-service/lib/Service.js:236:26)
at Service.resolveWebpackConfig (/home/riyad/Desktop/todo_wedevs/todo/node_modules/@vue/cli-service/lib/Service.js:240:48)
at PluginAPI.resolveWebpackConfig (/home/riyad/Desktop/todo_wedevs/todo/node_modules/@vue/cli-service/lib/PluginAPI.js:132:25)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todo@0.1.0 serve: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todo@0.1.0 serve 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! /home/riyad/.npm/_logs/2020-08-20T11_40_44_196Z-debug.log
我以为是少安装了什么包,于是删除nodemoudels,从新安装,然后还是这样;
然后各种网上查阅文档,终于在一篇老外的文档中发现二楼解决办法:
首先删除nodemodels:
更新npm: npm install npm@latest -g
然后:npm i --save-dev vue-loader-v16
删除错误日志
从新cnpm install
然后运行npm run serve
奇迹的事情发生了,没有报错直接运行;