我已经实现了一个有角度的2 + asp .net核心项目。现在我正在尝试将其升级到Angular 4.0。我的package.json是
{
"name": "Angular2Spa",
"version": "0.0.0",
"dependencies": {
"@angular/common": "4.0.2",
"@angular/compiler": "4.0.2",
"@angular/core": "4.0.2",
"@angular/forms": "4.0.2",
"@angular/http": "4.0.2",
"@angular/animations": "4.0.2",
"@angular/platform-browser": "4.0.2",
"@angular/platform-browser-dynamic": "4.0.2",
"@angular/platform-server": "^2.4.5",
"@angular/router": "4.0.2",
"@types/node": "^6.0.42",
"angular2-platform-node": "~2.0.10",
"angular2-universal": "~2.0.10",
"angular2-universal-polyfills": "~2.0.10",
"aspnet-prerendering": "^1.0.6",
"aspnet-webpack": "^1.0.11",
"bootstrap": "^3.3.7",
"css": "^2.2.1",
"css-loader": "^0.25.0",
"es6-shim": "^0.35.1",
"expose-loader": "^0.7.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"isomorphic-fetch": "^2.2.1",
"jquery": "^2.2.1",
"ng2-validation": "^3.9.1",
"preboot": "^4.5.2",
"raw-loader": "^0.5.1",
"rxjs": "5.0.0-beta.12",
"style-loader": "^0.13.0",
"to-string-loader": "^1.1.5",
"ts-loader": "^0.8.2",
"typescript": "^2.0.0",
"url-loader": "^0.5.7",
"webpack-externals-plugin": "^1.0.0",
"webpack": "2.2.0",
"webpack-hot-middleware": "2.12.2",
"webpack-merge": "4.1.0",
"zone.js": "0.8.5"
},
"devDependencies": {
"webpack": "2.2.0"
}
}
我收到错误
无法阅读财产' getDOM'未定义的
在node_modules \ angular2-platform-node \ get-dom.js文件中,其中包含以下代码:
var platform_browser_1 = require('@angular/platform-browser');
var getDOM = platform_browser_1.__platform_browser_private__.getDOM;
exports.getDOM = getDOM;
请指教。
答案 0 :(得分:1)
我想你可能会在这里混合......
尝试删除
"angular2-platform-node": "~2.0.10",
"angular2-universal": "~2.0.10",
"angular2-universal-polyfills": "~2.0.10",
执行:
npm install @angular/common@latest @angular/compiler@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest --save
确保您拥有更新的package.json。
如果您迁移到版本4,则不应发生此"@angular/platform-server": "^2.4.5",
。我个人使用此代码:"@angular/platform-server": "^4.0.1",
。
问题是你不必混合使用RC。确保您拥有全部或版本4或版本2.我知道迁移可能非常烦人。
以下是2个非常有用的迁移链接: