微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

角度 aot 构建显示 node_module typescript.js

如何解决角度 aot 构建显示 node_module typescript.js

当我使用 prod=true 和 aot=true 运行 ng build 命令时,这些错误就会出现。

错误:类型错误:无法读取未定义的属性“类型” 在 Object.getEffectiveTypeAnnotationNode (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:9432:18) 在assignContextualParameterTypes (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:37839:25) 在 checkFunctionExpressionorObjectLiteralMethod (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:38136:29) 在 checkExpressionWorker (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:39148:28) 在 checkExpression (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:39077:42) 在 checkBinaryLikeExpression (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:38657:29) 在 checkBinaryExpression (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:38649:20) 在 checkExpressionWorker (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:39169:28) 在 checkExpression (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:39077:42) 在 checkBinaryLikeExpression (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:38657:29) 在 checkBinaryExpression (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:38649:20) 在 checkExpressionWorker (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:39169:28) 在 checkExpression (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:39077:42) 在 checkExpressionStatement (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:41199:13) 在 checkSourceElement (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:43009:28) 在 Object.forEach (/Users/zawhtetaung/Documents/Brainlitz-Web/node_modules/typescript/lib/typescript.js:1500:30)

这是我的 tsconfig.json

{
  "compileOnSave": false,"compilerOptions": {
    "outDir": "./dist/out-tsc","sourceMap": true,"declaration": false,"moduleResolution": "node","allowJs": true,"emitDecoratorMetadata": true,"experimentalDecorators": true,"target": "es5","typeRoots": ["node_modules/@types"],"lib": ["es2017","dom"]
  }
}

这是我的 package.json 依赖项

"devDependencies": {
    "@angular/cli": "~1.7.3","@angular/compiler-cli": "^5.2.11","@angular/language-service": "^5.2.11","@types/jasmine": "^2.8.8","@types/jasminewd2": "~2.0.2","@types/node": "^6.0.112","codelyzer": "^4.0.1","husky": "^2.3.0","jasmine-core": "~2.8.0","jasmine-spec-reporter": "~4.2.1","karma": "~2.0.0","karma-chrome-launcher": "~2.2.0","karma-coverage-istanbul-reporter": "^1.4.3","karma-jasmine": "~1.1.0","karma-jasmine-html-reporter": "^0.2.2","lint-staged": "^8.2.1","prettier": "^1.18.2","protractor": "~5.1.2","ts-node": "~4.1.0","tslint": "~5.9.1","typescript": "~2.5.3"
  }

我不知道从哪里开始,因为我从来没有在 node_modules 中遇到过错误,但我想也许是版本不匹配?我已经在谷歌上搜索了足够多的东西,但找不到任何我可以使用的东西。所以任何想法都将不胜感激,谢谢。

解决方法

Aight 由于没有人回答,我只是将 typescript 版本升级到 2.6.2 并且很好。所以是版本不匹配的问题。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。