2016-05-23 81 views
0

在运行“故宫开始”,我收到以下错误:在运行将输出文件,而不是JavaScript文件过程中发生NPM启动错误2

app/app.component.ts(1,27): error TS2307: Cannot find module '@angular/core'. 
    app/main.ts(1,30): error TS2307: Cannot find module '@angular/platform-browser-dynamic'. 

npm ERR! weird error 2 

npm WARN This failure might be due to the use of legacy binary "node" 

npm WARN For further explanations, please read 
/usr/share/doc/nodejs/README.Debian 

错误。我甚至尝试了以下两条命令:

sudo apt-get install nodejs-legacy 


sudo npm update -g && sudo npm install -g concurrently lite-server typescript 

但仍然错误仍然存​​在。该怎么办? 我使用的是Ubuntu 14.04操作系统。节点版本:6.2.0,nodejs:0.10.25并且在Angular2上工作。

+0

你能提供你的'package.json'和'tsconfig.json'文件的内容吗?谢谢! –

+0

您是否在项目目录中执行了'npm install'(而不是'-g'或其他)? – CherryDT

+0

@CherryDT是的。它没有奏效。然后我尝试了'sudo npm install',它对我很有用。但仍然为什么它的工作,我不知道。 – hithard

回答

0

而不是使用:npm install。 使用:sudo npm install在同一个目录下,为我工作。

您还可以:sudo npm install -g将其安装到全球。 但是,请记住要在系统中安装最新的nodejs。 希望有所帮助。

不要忘记使用angular2库。

为了消除,以下错误: app/app.component.ts(1,27): error TS2307: Cannot find module '@angular/core'. app/main.ts(1,30): error TS2307: Cannot find module '@angular/platform-browser-dynamic'.

务必: npm install angular2 --save

,并替代进口:

import {Component} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; 希望它helps.If不一定做评论。

+0

Angular2包装声明已从RC1中的'angular2'更改为'@angular' – shershen