总得说来报这种Error: Can't resolve+模块名字的错误,一般就只有两种原因:一、少了这个包(直接安装:pnpm add -D 模块名字@版本),二、有这个包,但是版本在package.json中不正确。
需要和你的vue/cli-service的版本对应上,该降级的时候降级,降级一般先删除再安装新的
pnpm remove css-loader
pnpm add -D css-loader@3
vue/cli-service": "^3.8.0" 的package.json的相关的配置直接拿去可用:
{
"name": "default",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "npm run serve",
"serve": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
"build": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build"
},
"dependencies": {
"@better-scroll/core": "^2.5.1",
"axios": "^0.21.1",
"babel-loader": "^8.3.0",
"better-scroll": "^2.5.1",
"cache-loader": "^4.1.0",
"cnpm": "^9.3.2",
"core-js": "^2.6.5",
"element-ui": "^2.15.5",
"regenerator-runtime": "^0.14.1",
"swiper": "^6.8.1",
"vue": "^2.6.10",
"vue-baidu-map": "^0.21.22",
"vue-router": "^3.5.2",
"vue-seamless-scroll": "^1.1.23",
"vuex": "^3.6.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.8.0",
"@vue/cli-service": "^3.8.0",
"css-loader": "3",
"postcss-loader": "3",
"url-loader": "^4.1.1",
"vue-loader": "^15.11.1",
"vue-style-loader": "^4.1.3",
"vue-template-compiler": "^2.6.10"
}
}
最后解决问题:
标签:vue,cli,service,loader,resolve,Error From: https://www.cnblogs.com/CarlJohnson9527/p/17930014.html