问题描述
使用vue/cli创建的 typescript小程序项目,项目启动无问题,打包时报错Cannot read property 'options' of undefined
复现步骤
项目地址: https://github.com/swing-hh/uni-mp-template.git
预期结果
npm run build:mp-weixin 项目打包成功
实际结果
回溯到创建项目的阶段也是这个错误
`小程序各家浏览器内核及自定义组件实现机制存在差异,可能存在样式布局兼容问题,参考: https://uniapp.dcloud.io/matter?id=mp
⠙ 开始编译当前项目至 mp-weixin 平台...Starting type checking service...
Using 1 worker with 2048MB memory limit
⠦ 开始编译当前项目至 mp-weixin 平台...
ERROR Failed to compile with 3 errors 下午4:16:06
error in ./src/main.ts
Module build failed (from ./node_modules/_thread-loader@ 2.1.3@thread-loader /dist/cjs.js):
Thread Loader (Worker 0)
Cannot read property 'options' of undefined
at PoolWorker.fromErrorObj (/Users/yaojintao/yaobai/uni-mp-template/node_modules/_thread-loader@ 2.1.3@thread-loader /dist/WorkerPool.js:262:12)
at /Users/yaojintao/yaobai/uni-mp-template/node_modules/thread-loader@ 2.1.3@thread-loader /dist/WorkerPool.js:204:29
at Object. (/Users/yaojintao/yaobai/uni-mp-template/node_modules/@dcloudio_uni-cli-shared@2.0.0-alpha-29520201016001@@dcloudio/uni-cli-shared/lib/platform.js:26:43)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module.load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object. (/Users/yaojintao/yaobai/uni-mp-template/node_modules/@dcloudio_uni-cli-shared@2.0.0-alpha-29520201016001@@dcloudio/uni-cli-shared/lib/index.js:61:5)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
error in ./src/main.ts?{"page":"pages%2Fmy%2Findex"}
Module build failed (from ./node_modules/_thread-loader@ 2.1.3@thread-loader /dist/cjs.js):
Thread Loader (Worker 1)
Cannot read property 'options' of undefined
at PoolWorker.fromErrorObj (/Users/yaojintao/yaobai/uni-mp-template/node_modules/_thread-loader@ 2.1.3@thread-loader /dist/WorkerPool.js:262:12)
at /Users/yaojintao/yaobai/uni-mp-template/node_modules/thread-loader@ 2.1.3@thread-loader /dist/WorkerPool.js:204:29
at Object. (/Users/yaojintao/yaobai/uni-mp-template/node_modules/@dcloudio_uni-cli-shared@2.0.0-alpha-29520201016001@@dcloudio/uni-cli-shared/lib/platform.js:26:43)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module.load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object. (/Users/yaojintao/yaobai/uni-mp-template/node_modules/@dcloudio_uni-cli-shared@2.0.0-alpha-29520201016001@@dcloudio/uni-cli-shared/lib/index.js:61:5)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
error in ./src/main.ts?{"page":"pages%2Findex%2Findex"}
Module build failed (from ./node_modules/_thread-loader@ 2.1.3@thread-loader /dist/cjs.js):
Thread Loader (Worker 2)
Cannot read property 'options' of undefined
at PoolWorker.fromErrorObj (/Users/yaojintao/yaobai/uni-mp-template/node_modules/_thread-loader@ 2.1.3@thread-loader /dist/WorkerPool.js:262:12)
at /Users/yaojintao/yaobai/uni-mp-template/node_modules/thread-loader@ 2.1.3@thread-loader /dist/WorkerPool.js:204:29
at Object. (/Users/yaojintao/yaobai/uni-mp-template/node_modules/@dcloudio_uni-cli-shared@2.0.0-alpha-29520201016001@@dcloudio/uni-cli-shared/lib/platform.js:26:43)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module.load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object. (/Users/yaojintao/yaobai/uni-mp-template/node_modules/@dcloudio_uni-cli-shared@2.0.0-alpha-29520201016001@@dcloudio/uni-cli-shared/lib/index.js:61:5)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
ERROR Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! uni-mp-template@0.1.0 build:mp-weixin: cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the uni-mp-template@0.1.0 build:mp-weixin 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! /Users/yaojintao/.npm/_logs/2020-10-19T08_16_06_482Z-debug.log`
4条答案
按热度按时间ojsjcaue1#
同样的问题
hlswsv352#
同样的问题,我发现是 lock文件不同。更换npm源为淘宝立马解决了。谁能解释一下?
sqougxex3#
同样的问题,没找到解决方案
c7rzv4ha4#
App报这个错误,解决: parallel: false, 启用/禁用多进程并行运行。性能构建有一定影响