【发布时间】:2016-05-25 15:11:10
【问题描述】:
在运行“npm start”时,我收到以下错误:
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
错误发生在运行 typescript 文件时,而不是在 javascript 文件期间。我什至尝试过以下两个命令:
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 上工作。
【问题讨论】:
-
您能提供您的
package.json和tsconfig.json文件的内容吗?谢谢! -
您是否在项目目录中执行了
npm install(不是-g或其他任何操作)? -
@CherryDT 是的。它没有用。然后我尝试了
sudo npm install,它对我有用。但为什么它仍然有效,我不知道。 -
那么请添加您的解决方案作为答案!