2017-03-07 81 views
4

我遵循angular.io的步骤来安装angular-cli并创建基础项目。 它无法每次都提供或构建。我删除了npm,节点,所有节点dep。依然没有。使用不同版本的angular-cli(beta28)获取相同的错误。使用Angular-CLI进行Angular 2安装

ng -v

@angular/cli: 1.0.0-rc.1 
node: 6.10.0 
os: darwin x64 
@angular/common: 2.4.9 
@angular/compiler: 2.4.9 
@angular/core: 2.4.9 
@angular/forms: 2.4.9 
@angular/http: 2.4.9 
@angular/platform-browser: 2.4.9 
@angular/platform-browser-dynamic: 2.4.9 
@angular/router: 3.4.9 
@angular/cli: 1.0.0-rc.1 
@angular/compiler-cli: 2.4.9 

的错误,我越来越:

ERROR in multi ./src/styles.css 
Module not found: Error: Can't resolve 'style-loader' in '/Users/sebastian/workspace/ellipsis/frontend' 
@ multi ./src/styles.css 

ERROR in multi ./src/main.ts 
Module not found: Error: Can't resolve '@ngtools/webpack' in '/Users/sebastian/workspace/ellipsis/frontend' 
@ multi ./src/main.ts 

ERROR in multi ./src/polyfills.ts 
Module not found: Error: Can't resolve '@ngtools/webpack' in '/Users/sebastian/workspace/ellipsis/frontend' 
    @ multi ./src/polyfills.ts 
ERROR in Error: Child compilation failed: 
    Entry module not found: Error: Can't resolve 'raw-loader' in '/Users/sebastian/workspace/ellipsis/frontend': 
    Error: Can't resolve 'raw-loader' in '/Users/sebastian/workspace/ellipsis/frontend' 

因此,我安装一个个都需要的模块。但是,我留下了另一个不再是缺失模块的错误。

我不认为应该有必要一个接一个地安装这个模块。我在这里错过了什么?

运行OSX塞拉利昂

+0

尝试运行webpack --display-error-details。错误可能与文件分辨率无关.https://github.com/webpack/webpack/issues/981 – flakerimi

+0

您是否每次重新安装angular-cli时都创建该项目?或者你每次都使用自己的代码库? –

+0

我是'rm -rf project-name'和'ng project-name' cd - >'ng build' – Trouble

回答

2

使用@angular/cli,而不是

npm uninstall angular-cli 

npm cache clean 

npm install @angular/cli 

ng new myApp 

ng serve 
+0

获取完全相同的错误。我遵循angular.io的步骤,你们没有太大的不同,只是重新安装我已经安装的东西。 – Trouble

+0

运行这些命令:'npm install style-loader'和'npm install @ ngtools/webpack'和'npm install raw-loader' –

+1

不得不手动安装一堆其他模块。所有那里,仍然有错误: './src/main.ts中的错误 模块构建失败:TypeError:无法在Object处读取未定义的 属性'newLine'。getNewLineCharacter(/Users/sebastian/workspace/ellipsis/frontend/node_modules/typescript/lib/typescript.js:8062:20) at Object.createCompilerHost(/ Users/sebastian/workspace/ellipsis/frontend/node_modules/typescript/lib/typescript.js:44978:26) at Object.ngcLoader(/Users/sebastian/workspace/ellipsis/frontend/node_modules/@ngtools/webpack/src/loader.js:338:33) @ multi ./src/main .ts' – Trouble

1

我觉得你还在使用RC CLI的版本,我用下面的版本,请检查和更新如果有什么不同

"angular-cli": "1.0.0-beta.21", 
"@angular/common": "~2.4.1", 
"@angular/compiler": "~2.4.1", 
"@angular/core": "~2.4.1", 
"@angular/forms": "~2.4.1", 
"@angular/http": "~2.4.1", 
"@angular/platform-browser": "~2.4.1", 
"@angular/platform-browser-dynamic": "~2.4.1", 
"@angular/router": "~3.1.0", 
0

我相信如果你清理节点模块并重新安装都应该正常工作。

+0

阅读我已提供的信息。它不能正常工作。 – Trouble

0

如果您安装了旧版本的Node.js,然后安装最新的版本,它将更新旧版本,但仍旧会重新尝试旧的引用。

解决此问题的方法是从添加/删除 程序中卸载较旧版本的Node.js,并安装最新Node.js的新实例。 然后运行“npm install -g @ angular/cli”命令提示符。它会安装CLI组件。