相关平台
微信小程序
小程序基础库: 无
使用框架: Vue 2
复现步骤
按照教程创建项目
Taro init myApp
然后选择vue2
默认模板
Typescript no
npm run dev:weapp
后报错,
npm run build:weapp -- --watch
myApp@1.0.0 build:weapp
taro build --type weapp "--watch"
👽 Taro v3.3.12
Tips: 预览模式生成的文件较大,设置 NODE_ENV 为 production 可以开启压缩。
Example:
$ NODE_ENV=production taro build --type weapp --watch
启动 开发者工具-项目目录 /UserWebStorm/myApp/dist
生成 工具配置 /UserWebStorm/myApp/dist/project.config.json
编译 发现入口 src/app.js
编译 发现页面 src/pages/index/index.vue
Rule can only have one resource source (provided resource and test include exclude) in {
"exclude": [
null
],
"use": [
{
"loader": "/UserWebStorm/myApp/node_modules/babel-loader/lib/index.js",
"options": "undefined",
"ident": "undefined"
}
]
}
Rule can only have one resource source (provided resource and test include exclude) in {
"exclude": [
null
],
"use": [
{
"loader": "/UserWebStorm/myApp/node_modules/babel-loader/lib/index.js",
"options": "undefined",
"ident": "undefined"
}
]
}
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^
Error: Rule can only have one resource source (provided resource and test include exclude) in {
"exclude": [
null
],
"use": [
{
"loader": "/UserWebStorm/myApp/node_modules/babel-loader/lib/index.js",
"options": "undefined",
"ident": "undefined"
}
]
}
at checkResourceSource (/UserWebStorm/myApp/node_modules/@tarojs/mini-runner/node_modules/webpack/lib/RuleSet.js:167:11)
at Function.normalizeRule (/UserWebStorm/myApp/node_modules/@tarojs/mini-runner/node_modules/webpack/lib/RuleSet.js:198:4)
at /UserWebStorm/myApp/node_modules/@tarojs/mini-runner/node_modules/webpack/lib/RuleSet.js:110:20
at Array.map ()
at Function.normalizeRules (/UserWebStorm/myApp/node_modules/@tarojs/mini-runner/node_modules/webpack/lib/RuleSet.js:109:17)
at new RuleSet (/UserWebStorm/myApp/node_modules/@tarojs/mini-runner/node_modules/webpack/lib/RuleSet.js:104:24)
at new NormalModuleFactory (/UserWebStorm/myApp/node_modules/@tarojs/mini-runner/node_modules/webpack/lib/NormalModuleFactory.js:115:18)
at Compiler.createNormalModuleFactory (/UserWebStorm/myApp/node_modules/@tarojs/mini-runner/node_modules/webpack/lib/Compiler.js:636:31)
at Compiler.newCompilationParams (/UserWebStorm/myApp/node_modules/@tarojs/mini-runner/node_modules/webpack/lib/Compiler.js:653:30)
at Compiler.compile (/UserWebStorm/myApp/node_modules/@tarojs/mini-runner/node_modules/webpack/lib/Compiler.js:661:23)
at /UserWebStorm/myApp/node_modules/@tarojs/mini-runner/node_modules/webpack/lib/Watching.js:77:18
at _next0 (eval at create (/UserWebStorm/myApp/node_modules/tapable/lib/HookCodeFactory.js:33:10), :16:1)
at eval (eval at create (/UserWebStorm/myApp/node_modules/tapable/lib/HookCodeFactory.js:33:10), :24:1)
at TaroMiniPlugin. (/UserWebStorm/myApp/node_modules/@tarojs/mini-runner/src/plugins/MiniPlugin.ts:163:7)
at Generator.next ()
at fulfilled (/UserWebStorm/myApp/node_modules/@tarojs/mini-runner/dist/plugins/MiniPlugin.js:5:58)
期望结果
运行不报错。
实际结果
报错
环境信息
👽 Taro v3.3.12
Taro CLI 3.3.12 environment info:
System:
OS: macOS 11.6
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.4.0 - /usr/local/bin/node
npm: 7.20.6 - /usr/local/bin/npm
4条答案
按热度按时间hpxqektj1#
这个是node环境问题,可以尝试降低为原来的node版本应该就可以了。
zpqajqem2#
我把 package.json 里面的 webpack版本改为 4.0.0解决了这个问题。但是具体会不会引发其他问题还不清楚。
"webpack": "^4.0.0"
e5nszbig3#
谢谢你朋友!
cczfrluj4#
只需要在package.json中的
"devDependencies"添加 "webpack":"^4.46.0"(4.x都行)