将角度/材料添加到项目中

时间:2018-05-09 08:18:47

标签: angular angular-material npm-install

我正在尝试将角度/材质添加到我的项目中,当我使用命令安装它时:

npm install --save @angular/material @angular/cdk

我收到消息

+-- UNMET PEER DEPENDENCY @angular/cdk@6.0.1-9dadf37 (git://github.com/angular/cdk-builds.git#0f77998028a96b0684b1fc63e83b08d17b4a796e)
+-- UNMET PEER DEPENDENCY @angular/common@5.2.10
+-- UNMET PEER DEPENDENCY @angular/core@5.2.10
+-- @angular/material@6.0.1
`-- UNMET PEER DEPENDENCY popper.js@^1.14.3

当我尝试安装时:

npm install @angular/cdk@6.0.1-9dadf37

我收到此错误:

    npm ERR! Windows_NT 10.0.15063
    npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "@angular/cdk@6.0.1-9dadf37"
    npm ERR! node v6.9.1
    npm ERR! npm  v3.10.8
    npm ERR! code ETARGET

    npm ERR! notarget No compatible version found: @angular/cdk@6.0.1-9dadf37
    npm ERR! notarget Valid install targets:
    npm ERR! notarget 6.0.1, 6.0.0, 6.0.0-rc.14, 6.0.0-rc.13, 6.0.0-rc.12, 6.0.0-rc.11, 6.0.0-rc.10, 6.0.0-rc.9, 6.0.0-rc.8, 6.0.0-rc.7, 6.0.0-rc.6, 6.0.0-rc.5, 6.0.0-rc.4, 6.0.0-rc.3, 6.0.0-rc.2, 6.0.0-rc.1, 6.0.0-rc.0, 6.0.0-beta-0, 6.0.0-beta.5, 6.0.0-beta.4, 6.0.0-beta.3, 6.0.0-beta.2, 6.0.0-beta.1, 5.2.5, 5.2.4, 5.2.3, 5.2.2, 5.2.1, 5.2.0, 5.2.0-beta.0, 5.1.1, 5.1.0, 5.0.4, 5.0.3, 5.0.2, 5.0.1, 5.0.0, 5.0.0-rc0, 5.0.0-rc.3, 5.0.0-rc.2, 5.0.0-rc.1, 5.0.0-rc.0, 2.0.0-beta.12, 2.0.0-beta.11, 2.0.0-beta.10, 2.0.0-beta.9, 2.0.0-beta.8
    npm ERR! notarget
    npm ERR! notarget This is most likely not a problem with npm itself.
    npm ERR! notarget In most cases you or one of your dependencies are requesting
    npm ERR! notarget a package version that doesn't exist.

    npm ERR! Please include the following file with any support request:
    npm ERR!     C:\Users\user\project\angular-tour-of-heroes\npm-debug.log

当我尝试安装

    npm install @angular/common@5.2.10

我明白了:

npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "@angular/common@5.2.10"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! path C:\Users\user\project\angular-tour-of-heroes\node_modules\@angular\common
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename

npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\user\project\angular-tour-of-heroes\node_modules\@angular\common' -> 'C:\Users\user\project\angular-tour-of-heroes\node_modules\@angular\.common.DELETE'

这是我正在使用的角度版本:

Angular CLI: 1.7.4
Node: 6.9.1
OS: win32 x64
Angular: 5.2.10

我该怎么办?

1 个答案:

答案 0 :(得分:0)

最新的Angular Material需要Angular 6,按照this升级到版本6然后执行:

ng update @angular/material