事先我对我的英语感到遗憾。
我在Angular项目中run ng build --prod
时遇到问题。返回此错误。
错误中的错误:错误:内部错误:未定义的未知标识符
at Object.importExpr $$ 1 [as importExpr](.. \ node_modules \ @angular \ compiler \ bundles \ compiler.umd.js)
at tokenExpr(node_modules \ @angular \ compiler \ bundles \ compiler.umd.js)
在providerDef(node_modules \ @angular \ compiler \ bundles \ compiler.umd.js)
在node_modules \ @angular \ compiler \ bundles \ compiler.umd.js
在Array.map(本机)
在NgModuleCompiler.compile(node_modules \ @angular \ compiler \ bundles \ compiler.umd.js)
在AotCompiler._compileModule(node_modules \ @angular \ compiler \ bundles \ compiler.umd.js)
在node_modules \ @angular \ compiler \ bundles \ compiler.umd.js
at Array.forEach(native)
在AotCompiler._compileImplFile(node_modules \ @angular \ compiler \ bundles \ compiler.umd.js)
在node_modules \ @angular \ compiler \ bundles \ compiler.umd.js
在Array.map(本机)
在AotCompiler.emitAllImpls(node_modules \ @angular \ compiler \ bundles \ compiler.umd.js)
在AngularCompilerProgram.generateFilesForEmit(node_modules \ @angular \ compiler-cli \ src \ transformers \ program.js)
在AngularCompilerProgram.emit(node_modules \ @angular \ compiler-cli \ src \ transformers \ program.js)
在AngularCompilerPlugin._emit(node_modules \ @ngtools \ webpack \ src \ angular_compiler_plugin.js)
我的package.json
{
...
"private": true,
"dependencies": {
"@angular/animations": "^5.0.0",
"@angular/cdk": "^5.2.4",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/material": "^5.2.4",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/platform-server": "^5.0.0",
"@angular/router": "^5.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "^1.7.3",
"@angular/compiler-cli": "^5.0.0",
"@angular/language-service": "^4.2.4",
"@types/hammerjs": "^2.0.34",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"ng2-translate": "^5.0.0",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "2.4.2"
...
}
}
当我开始服务或ng构建没有错误。 谁有这个问题,告诉我如何解决它。
答案 0 :(得分:0)
使用ng-package
发布存储库时,repo's
根目录不应包含任何dist /目录,这意味着所有最终.js & .es5.js
文件应存在于根目录中已发布的存储库。
假设您有一个名为myRepo
的存储库,那么最终的层次结构应该与此类似:
---myRepo
---------myRepo.js
---------myRepo.es5.js
---------bundles/
---------src/ (contains definition files for components, services, etc)
在任何其他项目中使用myRepo时,就是这种情况,所有导入都应该类似于:
import {myService} from 'myRepo'
import {myModule} from 'myRepo'
现在,如果您运行ng build --prod
,则不得出现任何错误。
请查看reference
答案 1 :(得分:0)
尝试在控制台进行项目以进行npm安装这将安装最后的软件包可能存在问题,当你做这个时它会将所有软件包更新到最新版本。