我不会构建一个有角度的应用程序
Posted
技术标签:
【中文标题】我不会构建一个有角度的应用程序【英文标题】:I'm no getting to building an angular app 【发布时间】:2020-05-22 23:25:07 【问题描述】:谁能帮助解决以下问题?我被困在这3天了。我真的很感激
我尝试了很多东西,但似乎越来越糟糕。
我正在尝试使用 ng build --prod 构建一个 Angular 应用程序,但出现以下错误:
./node_modules/ngx-currency/fesm5/ngx-currency.js 模块中的错误 构建失败(从 ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js): TypeError:无法读取未定义的属性“种类” 在 isAngularDecoratorMetadataExpression (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\src\transforms\scrub-file.js:245:35) 在 checkNodeForDecorators (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\src\transforms\scrub-file.js:70:21) 在 visitNodes (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15788:30) 在 Object.forEachChild (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16014:24) 在 checkNodeForDecorators (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\src\transforms\scrub-file.js:61:31) 在 visitNode (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15779:24) 在 Object.forEachChild (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15909:21) 在 checkNodeForDecorators (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\src\transforms\scrub-file.js:61:31) 在 visitNode (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15779:24) 在 Object.forEachChild (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15966:24) 在 checkNodeForDecorators (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\src\transforms\scrub-file.js:61:31) 在 visitNode (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15779:24) 在 Object.forEachChild (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15977:24) 在 checkNodeForDecorators (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\src\transforms\scrub-file.js:61:31) 在 visitNode (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15779:24) 在 Object.forEachChild (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15873:21)
我的配置是:
tsconfig.json
"compileOnSave": false,
"angularCompilerOptions":
"disableTypeScriptVersionCheck": true
,
"compilerOptions":
"module": "esnext",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom",
"ES2017.object"
]
package.json
"name": "angular-ngrx-course",
"version": "0.0.0",
"license": "MIT",
"scripts":
"ng": "ng",
"start": "ng serve --proxy-config ./proxy.json",
"server": "ts-node -P ./server/server.tsconfig.json ./server/server.ts",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
,
"private": true,
"dependencies":
"@angular-devkit/schematics": "^8.0.0",
"@angular/animations": "^8.0.2",
"@angular/cdk": "^8.0.0",
"@angular/common": "^8.0.2",
"@angular/compiler": "^8.0.2",
"@angular/core": "^8.0.2",
"@angular/forms": "^8.0.2",
"@angular/material": "^8.0.0",
"@angular/material-moment-adapter": "^8.0.0",
"@angular/platform-browser": "^8.0.2",
"@angular/platform-browser-dynamic": "^8.0.2",
"@angular/router": "^8.0.2",
"@ngrx/data": "^8.0.1",
"@ngrx/effects": "^8.0.1",
"@ngrx/entity": "^8.0.1",
"@ngrx/router-store": "^8.0.1",
"@ngrx/store": "^8.0.1",
"@ngrx/store-devtools": "^8.0.1",
"body-parser": "^1.18.2",
"core-js": "^2.4.1",
"express": "^4.16.2",
"hammerjs": "^2.0.8",
"moment": "^2.22.2",
"rxjs": "^6.3.3",
"zone.js": "~0.9.1"
,
"devDependencies":
"@angular-devkit/build-angular": "~0.800.0",
"@angular/cli": "^8.0.1",
"@angular/compiler-cli": "^8.0.2",
"@angular/language-service": "^8.0.2",
"@ngrx/schematics": "^8.0.1",
"@types/express": "^4.0.39",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^5.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "^4.1.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^6.0.0",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~3.4.5"
【问题讨论】:
我认为 LppEdd 的回答可以帮助你:***.com/a/58188588/11382843 嗨@AnthonyRimet 感谢您的帮助。我试着做,LppEdd 显示的步骤,但它没有工作。 【参考方案1】:由于软件包版本不兼容,此问题出现在 prod build 中。 使用最新的可用软件包版本并不总是一个好主意,您应该尝试降级软件包版本来解决此类问题。
在控制台中检查哪个功能失败以及它属于哪个包,然后尝试将该包降级到稳定的发布版本。
【讨论】:
【参考方案2】:我用不那么简单的步骤解决了这个问题。
首先我卸载并安装了节点和 npm 之后,我在此链接中按照 IAMEVANHE 的食谱进行操作 https://github.com/nodejs/node-gyp/issues/119#issuecomment-318609877 老实说,它一开始并没有奏效,但我认为这可能是下面步骤之前的重要一步。 然后我将 angular 更新到版本 8。我必须解决 ViewChild 的一些简单问题,另一个是模块导入问题。
就是这样。我希望它可以帮助其他人。
【讨论】:
以上是关于我不会构建一个有角度的应用程序的主要内容,如果未能解决你的问题,请参考以下文章