您现在的位置是:首页 > 技术教程 正文

vue运行报错Error: Cannot find module ‘@vue/cli-plugin-babel‘

admin 阅读: 2024-03-29
后台-插件-广告管理-内容页头部广告(手机)

今天将VUE项目迁移到新的电脑上,配置不一样,导致报错:

Error: Cannot find module '@vue/cli-plugin-babel'
Require stack:
- D:\WWW\VUE\xxxxxx\node_modules\.store\@vue+ cli-service@5.0.8- D:\WWW\VUE\xxxxxx\node_modules\.store\@vue+cli-service@5.0.8\node_modules\@vue\cli-service\lib\Service.js
- D:\WWW\VUE\xxxxxx\node_modules\.store\@vue+ cli-service@5.0.8- D:\WWW\VUE\xxxxxx\node_modules\.store\@vue+cli-service@5.0.8\node_modules\@vue\cli-service\bin\vue-cli-service.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
at Module._load (node:internal/modules/cjs/loader:920:27)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at idToPlugin (D:\WWW\VUE\xxxxxx\node_modules\.store\@vue+ cli-service@5.0.8 at idToPlugin (D:\WWW\VUE\xxxxxx\node_modules\.store\@vue+cli-service@5.0.8\node_modules\@vue\cli-service\lib\Service.js:172:14)
at D:\WWW\VUE\xxxxxx\node_modules\.store\@vue+ cli-service@5.0.8 at D:\WWW\VUE\xxxxxx\node_modules\.store\@vue+cli-service@5.0.8\node_modules\@vue\cli-service\lib\Service.js:211:20
at Service.resolvePlugins (D:\WWW\VUE\xxxxxx\node_modules\.store\@vue+ cli-service@5.0.8 at Service.resolvePlugins (D:\WWW\VUE\xxxxxx\node_modules\.store\@vue+cli-service@5.0.8\node_modules\@vue\cli-service\lib\Service.js:198:10)
at Object. (D:\WWW\VUE\xxxxxx\node_modules\.store\@vue+ cli-service@5.0.8 at Object. (D:\WWW\VUE\xxxxxx\node_modules\.store\@vue+cli-service@5.0.8\node_modules\@vue\cli-service\bin\vue-cli-service.js:15:17) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'D:\\WWW\\VUE\\xxxxxx\\node_modules\\.store\\@vue+ cli-service@5.0.8 'D:\\WWW\\VUE\\xxxxxx\\node_modules\\.store\\@vue+cli-service@5.0.8\\node_modules\\@vue\\cli-service\\lib\\Service.js',
'D:\\WWW\\VUE\\xxxxxx\\node_modules\\.store\\@vue+ cli-service@5.0.8\\node_modules\\@vue\\cli-service\\bin\\vue-cli-service.js'
]
}

删除node_modules文件夹后执行命令

npm update

仍然报错缺少“@vue/cli-plugin-babel”

在网上找了半天的方法,才找到只言片语。

原因:当前电脑nodejs版本过高,项目的配置太低,不匹配,如下package.json

  1. {
  2. "dependencies": {
  3. "node-sass": "^4.13.1",
  4. "sass-loader": "^7.3.1",
  5. },
  6. "devDependencies": {
  7. "@vue/cli-plugin-babel": "~4.5.15",
  8. },
  9. }

node 版本与 node-sass 版本的对应关系:

查看文档的地址: https://www.npmjs.com/package/node-sass

解决方法,删除这几行配置,重新安装。

  1. npm install node-sass
  2. npm install sass-loader
  3. npm install @vue/cli-plugin-babel

重新运行问题解决

npm run serve
标签:
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

在线投稿:投稿 站长QQ:1888636

后台-插件-广告管理-内容页尾部广告(手机)
关注我们

扫一扫关注我们,了解最新精彩内容

搜索
排行榜