我最近升级到了节点6,角度4,打字稿2.3.2和@ angular / cli 1.02。我按照Guide关于如何升级@ angular / cli。 如果那里有任何相关内容,我会将我的整个package.json添加到下面。 我收到了这个错误:
ERROR in AppModule is not an NgModule
ERROR in ./src/main.ts
Module build failed: TypeError: Cannot read property 'newLine' of undefined
at Object.getNewLineCharacter (C:\development\projects-git\mydoc\static- web\node_modules\typescript\lib\typescript.js:9580:20)
at Object.createCompilerHost (C:\development\projects-git\mydoc\static-web\node_modules\typescript\lib\typescript.js:66674:26)
at Object.ngcLoader (C:\development\projects-git\mydoc\static-web\node_modules\@ngtools\webpack\src\loader.js:202:31)
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
指南中的我必须将main.ts
更新为:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/app.module';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
我的完整package.json
是:
{
"name": "angular2-app",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.1.1",
"@angular/common": "^4.1.1",
"@angular/compiler": "^4.1.2",
"@angular/core": "^4.1.2",
"@angular/forms": "^4.1.1",
"@angular/http": "^4.1.2",
"@angular/platform-browser": "^4.1.1",
"@angular/platform-browser-dynamic": "^4.1.1",
"@angular/platform-server": "^4.1.1",
"@angular/router": "^4.1.1",
"@ngtools/json-schema": "1.0.0",
"@ngtools/webpack": "1.2.3",
"@types/file-saver": "0.0.0",
"angular2-datatable": "^0.5.3",
"bootstrap-sass": "^3.3.7",
"core-js": "^2.4.1",
"file-saver": "^1.3.3",
"font-awesome": "^4.7.0",
"moment": "^2.18.1",
"mydatepicker": "^1.9.1",
"ng2-bootstrap": "^1.6.1",
"ng2-page-scroll": "^4.0.0-beta.5",
"@ngx-translate/core": "^6.0.0",
"rxjs": "^5.4.0",
"string-to-json": "^0.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "^1.0.2",
"@angular/compiler": "^4.1.2",
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"codelyzer": "~2.0.0",
"extract-text-webpack-plugin": "^2.0.0-rc.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "^1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-junit-reporter": "^1.2.0",
"karma-phantomjs-launcher-nonet": "0.1.3",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "2.3.2"
}
}
这使得构建不可能。
答案 0 :(得分:0)
这似乎是known issue。 确保已正确重新安装节点模块:
rm -rf node_modules && npm cache clean && npm uninstall --save angular-cli && npm uninstall -g angular-cli && npm i --save @angular/cli && npm i -g @angular/cli && npm i