我已经按照Angular2教程并在package.json文件中包含相关行:
"@angular/http": "2.0.0-rc.4",
然而,出于某种原因,当Angular2服务器模块(井节点,基本上......)尝试加载依赖项时,我得到404。谁能告诉我加载这种依赖的正确方法?所有其他依赖项加载正常,但我需要http模块加载来自JSON文件的数据。
运行npm install
时,我收到以下警告:
npm WARN cannot run in wd angular2-quickstart@1.0.0 typings install (wd=/root/OrderOfTheMouse2-0)
哪个可能与它有关?
此外,启动时的GET请求正在寻找以下路径,该路径似乎不存在:
[1] 16.08.07 19:52:31 404 GET /node_modules/angular2/bundles/http.dev.js
完整的package.json文件,按要求:
{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"license": "ISC",
"dependencies": {
"@angular/common": "2.0.0-rc.4",
"@angular/compiler": "2.0.0-rc.4",
"@angular/core": "2.0.0-rc.4",
"@angular/forms": "0.2.0",
"@angular/http": "2.0.0-rc.4",
"@angular/platform-browser": "2.0.0-rc.4",
"@angular/platform-browser-dynamic": "2.0.0-rc.4",
"@angular/router": "3.0.0-beta.1",
"@angular/router-deprecated": "2.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.4",
"angular2-in-memory-web-api": "0.0.14",
"angular2-log": "0.0.6",
"bootstrap": "^3.3.6",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"systemjs": "0.19.27",
"zone.js": "^0.6.12"
},
"devDependencies": {
"concurrently": "^2.0.0",
"gulp": "^3.9.1",
"lite-server": "^2.2.0",
"typescript": "^1.8.10",
"typings": "^1.0.4"
}
}
答案 0 :(得分:0)
我的猜测是你需要先运行npm install - g typings
命令。(警告信息也是如此)。然后尝试运行npm install
。