厦门第一帅哥
厦门第一帅哥
  • 发布:2021-09-29 13:47
  • 更新:2022-08-11 16:38
  • 阅读:11517

Error: Cannot find module 'webpack/lib/RuleSet'

分类:uni-app

拿了别人的项目来,npm install成功,运行后报错:

12:07:46.629  ERROR  Error: Cannot find module 'webpack/lib/RuleSet'  
12:07:46.638 Require stack:  
12:07:46.638 - /Users/zhaoliangchen/Desktop/zrhs/tobacco-customer/tobacco-customer-mobile/node_modules/@dcloudio/vue-cli-plugin-uni/lib/configure-webpack.js  
12:07:46.646 - /Users/zhaoliangchen/Desktop/zrhs/tobacco-customer/tobacco-customer-mobile/node_modules/@dcloudio/vue-cli-plugin-uni/index.js  
12:07:46.647 - /Users/zhaoliangchen/Desktop/zrhs/tobacco-customer/tobacco-customer-mobile/node_modules/@vue/cli-service/lib/Service.js  
12:07:46.657 - /Users/zhaoliangchen/Desktop/zrhs/tobacco-customer/tobacco-customer-mobile/node_modules/@vue/cli-service/bin/vue-cli-service.js  
12:07:46.657 Error: Cannot find module 'webpack/lib/RuleSet'  
12:07:46.680 Require stack:  
12:07:46.681 - /Users/zhaoliangchen/Desktop/zrhs/tobacco-customer/tobacco-customer-mobile/node_modules/@dcloudio/vue-cli-plugin-uni/lib/configure-webpack.js  
12:07:46.691 - /Users/zhaoliangchen/Desktop/zrhs/tobacco-customer/tobacco-customer-mobile/node_modules/@dcloudio/vue-cli-plugin-uni/index.js  
12:07:46.702 - /Users/zhaoliangchen/Desktop/zrhs/tobacco-customer/tobacco-customer-mobile/node_modules/@vue/cli-service/lib/Service.js  
12:07:46.703 - /Users/zhaoliangchen/Desktop/zrhs/tobacco-customer/tobacco-customer-mobile/node_modules/@vue/cli-service/bin/vue-cli-service.js  
12:07:46.719     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)  
12:07:46.721     at Function.Module._resolveFilename (/Users/zhaoliangchen/Desktop/zrhs/tobacco-customer/tobacco-customer-mobile/node_modules/module-alias/index.js:49:29)  
12:07:46.736     at Function.Module._load (internal/modules/cjs/loader.js:667:27)  
12:07:46.737     at Module.require (internal/modules/cjs/loader.js:887:19)  
12:07:46.752     at require (internal/modules/cjs/helpers.js:74:18)  
12:07:46.754     at Object.<anonymous> (/Users/zhaoliangchen/Desktop/zrhs/tobacco-customer/tobacco-customer-mobile/node_modules/@dcloudio/vue-cli-plugin-uni/lib/configure-webpack.js:4:17)  
12:07:46.770     at Module._compile (internal/modules/cjs/loader.js:999:30)  
12:07:46.787     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)  
12:07:46.788     at Module.load (internal/modules/cjs/loader.js:863:32)  
12:07:46.803     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
2021-09-29 13:47 负责人:无 分享
已邀请:
愉悦

愉悦

网上方法 都试过,无效,也不是webpack的版本的问题。

这个问题我解决了,和大家说一下,
是vue5.0的问题(暂时这么说),具体问题没研究。

解决方法如下:
1.卸载vue5.0

npm remove -g  @vue/cli

2.安装vue4.5.15(4.5版本最新版)

npm install -g @vue/cli@4.5.15

3.使用vue-cli创建uni-app

vue create -p dcloudio/uni-preset-vue my-project

会提示选择项目模板,我用的是默认模板

4.运行开发serve

cd [your-project]
yarn serve

npm run serve

过一会儿你将看到类似如下:
DONE Compiled successfully in 4137ms 4:25:35 ├F10: PM┤

App running at:

  • Local: http://localhost:8080/
  • Network: http://192.168.31.23:8080/
厦门第一帅哥

厦门第一帅哥 (作者) - 大前端开发

"dependencies": {  
    "@dcloudio/uni-app-plus": "^2.0.0-32920210927001",  
    "@dcloudio/uni-cli-i18n": "^2.0.0-32920210927001",  
    "@dcloudio/uni-h5": "^2.0.0-32920210927001",  
    "@dcloudio/uni-helper-json": "*",  
    "@dcloudio/uni-i18n": "^2.0.0-32920210927001",  
    "@dcloudio/uni-mp-360": "^2.0.0-32920210927001",  
    "@dcloudio/uni-mp-alipay": "^2.0.0-32920210927001",  
    "@dcloudio/uni-mp-baidu": "^2.0.0-32920210927001",  
    "@dcloudio/uni-mp-kuaishou": "^2.0.0-32920210927001",  
    "@dcloudio/uni-mp-qq": "^2.0.0-32920210927001",  
    "@dcloudio/uni-mp-toutiao": "^2.0.0-32920210927001",  
    "@dcloudio/uni-mp-vue": "^2.0.0-32920210927001",  
    "@dcloudio/uni-mp-weixin": "^2.0.0-32920210927001",  
    "@dcloudio/uni-quickapp-native": "^2.0.0-32920210927001",  
    "@dcloudio/uni-quickapp-webview": "^2.0.0-32920210927001",  
    "@dcloudio/uni-stat": "^2.0.0-32920210927001",  
    "@euler/mobile-ui": "^0.0.1",  
    "@vue/shared": "^3.0.0",  
    "core-js": "^3.6.5",  
    "flyio": "^0.6.2",  
    "regenerator-runtime": "^0.12.1",  
    "uview-ui": "^1.8.4",  
    "vue": "^2.6.11",  
    "vuex": "^3.2.0"  
  },  
  "devDependencies": {  
    "@babel/runtime": "~7.12.0",  
    "@dcloudio/types": "*",  
    "@dcloudio/uni-automator": "^2.0.0-32920210927001",  
    "@dcloudio/uni-cli-shared": "^2.0.0-32920210927001",  
    "@dcloudio/uni-migration": "^2.0.0-32920210927001",  
    "@dcloudio/uni-template-compiler": "^2.0.0-32920210927001",  
    "@dcloudio/vue-cli-plugin-hbuilderx": "^2.0.0-32920210927001",  
    "@dcloudio/vue-cli-plugin-uni": "^2.0.0-32920210927001",  
    "@dcloudio/vue-cli-plugin-uni-optimize": "^2.0.0-32920210927001",  
    "@dcloudio/webpack-uni-mp-loader": "^2.0.0-32920210927001",  
    "@dcloudio/webpack-uni-pages-loader": "^2.0.0-32920210927001",  
    "@vue/cli-plugin-babel": "~4.5.0",  
    "@vue/cli-service": "~4.5.0",  
    "babel-plugin-import": "^1.11.0",  
    "cross-env": "^7.0.2",  
    "html-webpack-plugin": "^5.3.2",  
    "jest": "^25.4.0",  
    "mini-types": "*",  
    "miniprogram-api-typings": "*",  
    "node-sass": "6.0.1",  
    "patch-package": "^6.4.7",  
    "postcss-comment": "^2.0.0",  
    "sass-loader": "^12.1.0",  
    "vue-template-compiler": "^2.6.11"  
  },  
  "browserslist": [  
    "Android >= 4",  
    "ios >= 8"  
  ],  
  "uni-app": {  
    "scripts": {}  
  }
Jjiawen1

Jjiawen1

大佬解决了么?我也遇到相同的问题,求大佬指点一下啊

  • 当心花儿

    同遇到,有人说用node12,但是我不行!求解!

    2022-02-24 15:10

  • 愉悦

    回复 当心花儿: 看我下面的回复

    2022-02-27 17:03

  • 愉悦

    看我下面的回复

    2022-02-27 17:03

  • Jjiawen1

    回复 愉悦: 已经解决了,确实是vuecli版本的问题,卸载5重新安装4.5解决了问题

    2022-02-28 13:42

l***@163.com

l***@163.com

我把node版本降低12还是不行,@vue/cli@4.5.15我也试过了还是不行,人都麻了

  • 5***@qq.com

    我也是 我cli都安装到3.11 了 还是不行 老项目真烦

    2023-02-13 22:07

DCloud_UNI_GSQ

DCloud_UNI_GSQ

https://ask.dcloud.net.cn/question/135817

要回复问题请先登录注册