gpt4 book ai didi

visual-studio - Angular2 - 不会为提前编译生成 ngfactory 文件

转载 作者:太空狗 更新时间:2023-10-29 18:32:11 30 4
gpt4 key购买 nike

我正在尝试使 Angular2 AoT 正常工作。不幸的是,当我执行 ngc 命令时,没有生成 .ngfactory 文件:

./node_modules/.bin/ngc" -p "./tsconfig-aot.json" --i18nFile="./app/compiled/localise.xlf" --locale=zh --i18nFormat=xlf

使用该配置,我的“JIT”编译工作正常,直到运行 ngc 命令,然后它也会破坏 JIT,直到重建解决方案。

它给出的错误:

(SystemJS) XHR error (404) loading https:// <domain>/<urlPath>/traceur
Error: XHR error (404) loading https:// <domain>/<urlPath>/traceur
at XMLHttpRequest.wrapFn [as _onreadystatechange] (https://<domain>/node_modules/zone.js/dist/zone.js:889:29) [<root>]
at Zone.runTask (https:// <domain>/node_modules/zone.js/dist/zone.js:151:47) [<root> => <root>]
at XMLHttpRequest.ZoneTask.invoke (https:// <domain>/node_modules/zone.js/dist/zone.js:345:33) [<root>]
Error loading https:// <domain>/<urlPath>/traceur
Unable to load transpiler to transpile https:// <domain>/<pathToMain>/main.js
Error loading https://<domain>/<pathToMain>/main.js

我的配置:

package.json:

{
"version": "1.0.0",
"name": "aspnet",
"private": true,
"scripts": {
"postinstall": "typings install",
"typings": "typings"
},
"dependencies": {
"@angular/common": "2.4.1",
"@angular/compiler": "2.4.1",
"@angular/compiler-cli": "2.4.1",
"@angular/core": "2.4.1",
"@angular/forms": "2.4.1",
"@angular/http": "2.4.1",
"@angular/platform-browser": "2.4.1",
"@angular/platform-browser-dynamic": "2.4.1",
"@angular/platform-server": "2.4.1",
"@angular/upgrade": "2.4.1",
"@types/node": "6.0.57",
"angular-in-memory-web-api": "0.2.4",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.2",
"systemjs": "0.19.41",
"zone.js": "^0.7.2"
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.0",
"gulp-tsc": "^1.2.0",
"gulp-typescript": "3.1.3",
"path": "^0.12.7",
"rollup": "0.40.2",
"rollup-plugin-commonjs": "7.0.0",
"rollup-plugin-multi-entry": "^2.0.1",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-uglify": "^1.0.1",
"typescript": "^2.0.2",
"typings": "2.1.0"
}
}

tsconfig-aot.json:

{
"compileOnSave": true,
"compilerOptions": {
"module": "es2015",
"noEmitOnError": true,
"noImplicitAny": false,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"typeRoots": [
"node_modules/@types"
]
},
"include": [
"app/**/*.ts"
],
"exclude": [
"node_modules",
"typings/index",
"typings/index.d.ts"
],
"angularCompilerOptions": {
"genDir": "app/compiled",
"skipMetadataEmit": true
}
}

tsconfig.json:

{
"compileOnSave": true,
"compilerOptions": {
"module": "commonjs",
"noEmitOnError": true,
"noImplicitAny": false,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"typeRoots": [
"node_modules/@types"
]
},
"include": [
"app/**/app.module.ts",
"app/**/*.ts"
],
"exclude": [
"node_modules",
"typings/index",
"typings/index.d.ts"
],
"angularCompilerOptions": {
"genDir": "app/compiled",
"skipMetadataEmit": true
}
}

还有 2.0.2 版本的 TypeScript

Angular 并且所有包都已更新到最新版本,但没有帮助。

npm install 被调用,并生成 node_modules

gulp 已被调用,libs 目录也已创建。

如有任何帮助,我们将不胜感激。

最佳答案

它可能不是 2.0.2,因为你的包 json 中有插入符号 (^)。

删除插入符(^),删除库,安装依赖项并重试。

像这样:"typescript": "2.0.2"

关于visual-studio - Angular2 - 不会为提前编译生成 ngfactory 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41504348/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com