简体   繁体   English

如何正确设置 Angular 2 项目

[英]How to Setup Angular 2 Project Properly

I use the following sample project to learn Angular 2:我使用以下示例项目来学习 Angular 2:

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

I did the following things:我做了以下几件事:

  1. after git clone https://bitbucket.org/syncfusiontech/angular-2-succinctly/overview I executed the following commands:git clone https://bitbucket.org/syncfusiontech/angular-2-succinctly/overview我执行了以下命令:
  2. cd AsBook
  3. npm install
  4. npm start

A new browser instance is opened, but remains with the message Loading... .一个新的浏览器实例被打开,但仍然显示消息Loading...

In the browser debug mode, I see the following errors:在浏览器调试模式下,我看到以下错误:

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

How do I have to correct the package.json file to set it up properly?我必须如何更正package.json文件才能正确设置它?

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"
} }

In index.html i see在 index.html 我看到

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

Try execute尝试执行

npm i jquery --save

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM