dcloudio / dcloudio/uni-app

使用vue/cli创建的typescript项目,项目打包报错 Cannot read property 'options' of undefined

Open
#2,198 4 comments 0 reactions 0 assignees View on GitHub
mp-weixin 提供了复现方案 评论中有最佳答案
Dominant language
JavaScript
Stars
41.6k
Forks
3.7k
Avg merge
7h 6m
Merged PRs (30d)
6

Description

**问题描述**
使用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`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.