簡體   English   中英

如何正確設置 Angular 2 項目

[英]How to Setup Angular 2 Project Properly

我使用以下示例項目來學習 Angular 2:

https://bitbucket.org/syncfusiontech/angular-2-succinctly/overview

我做了以下幾件事:

  1. git clone https://bitbucket.org/syncfusiontech/angular-2-succinctly/overview我執行了以下命令:
  2. cd AsBook
  3. npm install
  4. npm start

一個新的瀏覽器實例被打開,但仍然顯示消息Loading...

在瀏覽器調試模式下,我看到以下錯誤:

jquery.min.js Failed to load resource: the server responded with a status of 404 (Not Found) jquery.min.js Failed to load resource: the server responded with a status of 404 (Not Found) bootstrap.min.js:6 Uncaught ZoneAwareErrormessage: (...)name: (...)originalStack: (...)stack: (...)toSource: function ()toString: function ()zoneAwareStack: (...)__zone_symbol__error: Error: Bootstrap's JavaScript requires jQuery at http://localhost:3000/node_modules/bootstrap/dist/js/bootstrap.min.js:6:37 [<root>]get message: function ()set message: function (value)get name: function ()set name: function (value)arguments: (...)caller: (...)length: 1name: "set"prototype: Object__proto__: function ()[[FunctionLocation]]: zone.js:899[[Scopes]]: Scopes[4]get originalStack: function ()set originalStack: function (value)get stack: function ()set stack: function (value)get zoneAwareStack: function ()set zoneAwareStack: function (value)__proto__: Object :3000/app/main.js Failed to load resource: the server responded with a status of 404 (Not Found) localhost/:23 ZoneAwareError (anonymous) @ localhost/:23

我必須如何更正package.json文件才能正確設置它?

package.json :

{ "name": "helloworld", "version": "1.0.0", "description": "First Angular-2 application", "author":"Joe Booth", "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": "UNLICENSED", "private": true, "dependencies": { "@angular/common": "~2.3.0", "@angular/compiler": "~2.3.0", "@angular/core": "~2.3.0", "@angular/forms": "~2.3.0", "@angular/http": "~2.3.0", "@angular/platform-browser": "~2.3.0", "@angular/platform-browser-dynamic": "~2.3.0", "@angular/router": "~3.3.0", "bootstrap": "^3.3.6", "systemjs": "0.19.39",
"angular-in-memory-web-api": "~0.1.16", "core-js": "^2.4.1", "reflect-metadata": "^0.1.8", "rxjs": "5.0.0-rc.4", "zone.js": "^0.7.2" }, "devDependencies": { "concurrently": "^3.0.0", "lite-server": "^2.2.2", "typescript": "^2.0.3",
"typings": "^1.4.0"
} }

在 index.html 我看到

<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>

嘗試執行

npm i jquery --save

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM