Angular 2 npm start 报错
首先, index.html 和styles.css是和app目录平级的, 不要扔到里面去, 否则会404
确认配置文件齐全, 路径都正确之后 npm start
What?! 照着快速起步也会弄错吗? 人品问题吗?
很多人可能会看到npm报错:
- $ npm start
- > angular-quickstart@1.0. start F:\work\angular_quickstart\angular
- > tsc && concurrently "tsc -w" "lite-server"
- [] Did not detect a `bs-config.json` or `bs-config.js` override file. Using lite-server defaults...
- [] ** browser-sync config **
- [] { injectChanges: false,
- [] files: [ './**/*.{html,htm,css,js}' ],
- [] watchOptions: { ignored: 'node_modules' },
- [] server: { baseDir: './', middleware: [ [Function], [Function] ] } }
- [] :: - Compilation complete. Watching for file changes.
- [] [BS] Access URLs:
- [] --------------------------------------
- [] Local: http://localhost:3000
- [] External: http://192.168.155.1:3000
- [] --------------------------------------
- [] UI: http://localhost:3001
- [] UI External: http://192.168.155.1:3001
- [] --------------------------------------
- [] [BS] Serving files from: ./
- [] [BS] Watching files...
- [] 16.11. :: GET /index.html
- [] 16.11. :: GET /favicon.ico
除了404是上面说的文件摆放路径错误意外, 其实不需要care它的, 和正常启动应用无关, 属于npm版本相关问题, 此处不赘述。
重要的是console里面的log:
The module AppModule was bootstrapped, but it does not declare "@NgModule.bootstrap" components nor a "ngDoBootstrap" method. Please define one of these.
这句还是make sense的, 意思是
初始化的时候用的platform.bootstrapModule(), 却没有把bootstrap引用为[ AppComponent ]
问题就出在这里
这里是应用的入口点。
由于 QuickStart 是运行在浏览器中的 Web 应用,所以根模块需要从
@angular/platform-browser
中导入BrowserModule
并添加到imports
数组中。这是要让最小的应用在浏览器中运行时,对 Angular 的最低需求。
QuickStart 应用不做别的,也就先不需要其它模块。在真实的应用中,我们可能还得导入
FormsModule
、RouterModule
和HttpModule
。这些会在 英雄指南教程中引入。
官方文档上给的最低需求,低到连它自己给出的index.html都显示不出来了...
我老眼昏花只用了最低配置, 而没有看到就在下面几行它其实又贴了一次这个文件:
这才是 要用的!
You see, 改完这个文件以后应该就不会报错了, 最后的console应该变成这样:
Angular 2 npm start 报错的更多相关文章
- 执行npm install报错:npm ERR! code EINTEGRITY
命令行执行npm install报错如下: D:\frontend\viewsdev>npm install npm ERR! code EINTEGRITY npm ERR! sha512-8 ...
- npm install 报错:node-pre-gyp ERR! 问题解决
npm install报错问题解决 问题: E:\CodeSpace\GitlabTest\desktop>npm install > lifeccp-desktop@1.1.9 post ...
- vuejs npm chromedriver 报错
vuejs npm chromedriver 报错 # 全局安装 vue-cli$ npm install -g vue-cli# 创建一个基于 "webpack" 模板的新项 ...
- npm install 报错 error Unexpected end of JSON input while parsing near '...sShrinkwrap":false,"d' 解决办法
npm install 报错 : error Unexpected end of JSON input while parsing near '...sShrinkwrap":false,& ...
- 执行命令npm publish报错:403 Forbidden - PUT https://registry.npmjs.org/kunmomotest2 - You cannot publish over the previously published versions: 0.0.1.
前言 执行命令npm publish报错:403 Forbidden - PUT https://registry.npmjs.org/kunmomotest2 - You cannot publis ...
- 执行npm publish 报错:403 Forbidden - PUT https://registry.npmjs.org/kunmomotest - you must verify your email before publishing a new package: https://www.npmjs.com/email-edit
前言 执行npm publish 报错:403 Forbidden - PUT https://registry.npmjs.org/kunmomotest - you must verify you ...
- 执行npm publish 报错:401 Unauthorized - PUT https://registry.npmjs.org/kunmomotest - You must be logged in to publish packages.
前言 执行npm publish 报错:401 Unauthorized - PUT https://registry.npmjs.org/kunmomotest - You must be logg ...
- npm启动报错
npm 启动报错 event.js 160 报错原因: 端口号被占用 解决方法: 1.重新定义一个端口号. 2.任务管理器关掉node进程,重新运行npm.
- npm -v 报错:Error: EPERM: operation not permitted, mkdir 'C:\soft\nodejs'
npm -v 报错:Error: EPERM: operation not permitted, mkdir 'C:\soft\nodejs' 起因:原本安装node在C盘soft文件夹下,按node ...
随机推荐
- HTTP的报文格式,GET和POST的区别
1.HTTP报文格式 HTTP报文是面向文本的,报文中的每一个字段都是一些ASCII码串,各个字段的长度是不确定的.HTTP有两类报文:请求报文和响应报文. 请求报文: 一个HTTP请求报文由请求行( ...
- 【NodeJs】Ctrl+C在Linux平台和Windows平台下的TCP连接中的不同表现
Linux平台:CentOS release 6.5 (Final) Windows平台:Windows 7 旗舰版 服务器端代码如下: var net = require('net'); var s ...
- hdu2045java递推
不容易系列之(3)—— LELE的RPG难题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/O ...
- Android开发之ViewPager实现多页面切换及动画效果(仿Android的Launcher效果)
Android开发中经常会有引导页或者切换页面等效果,本文采用ViewPager结合动画效果来实现仿Launcher以及页面切换的效果.源码地址在文章最后给出下载. 效果图如下: 1.Vi ...
- Java基础知识强化之集合框架笔记50:Map集合之Map集合的概述和特点
1. Map集合的概述: public interface Map<K,V> 作为学生来说,是根据学号来区分不同的学生的,那么假设我现在已经知道了学生的学号,我要根据学号去获取学生姓名,请 ...
- System Operations on AWS - Lab 1W - Creating EC2 (Windows)
1. 创建CommandHost实例,登录到CommandHost,通过AWS CLI创建WebServer实例. 1.1 为CommandHost实例创建一个IAM角色 1.2 创建CommandH ...
- SQL语句中格式化时间
给数据库中的字段格式化(): to_char(CREATETIME,'yyyy-MM-dd') 给程序中的字段格式化(InTime为数据库字段): InTime = to_date( '" ...
- jQuery滑动并响应事件
jQuery滑动并打开指定页面: <!DOCTYPE html> <html> <head> <script src="http://code.jq ...
- asp.net页面刷新等问题
windows.open 关闭当前页面刷新父页面实现() { 在子页面中 Page.ClientScript.RegisterStartupScript(this.GetType(), "a ...
- 使用html5兼容低版本浏览器
因为html5 新出的一些语义化的标签,在低版本浏览器下不能识别,举个例子,比如你写了一个 header 标签中,写了一段文本,在低版本浏览器下,肯定是能看到的,但是,那是他是不认识 header标签 ...