Ionic 2安装失败 - 在Windows 10上安装ENOENT,EPERM

时间:2016-10-31 11:11:11

标签: ionic-framework npm ionic2 npm-install

我按照http://ionicframework.com/docs/v2/getting-started/installation/

中的说明在Windows 10上安装离子时出现以下错误ENOENT,EPERM

npm config

C:\WINDOWS\system32>npm config list
; cli configs
user-agent = "npm/3.10.8 node/v6.9.1 win32 x64"

; builtin config undefined
prefix = "C:\\Users\\developer\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\WINDOWS\system32
; HOME = C:\Users\developer
; "npm config ls -l" to show all defaults.

使用的命令

PS C:\WINDOWS\system32> node -v
v6.9.1
PS C:\WINDOWS\system32> npm -v
3.10.8
PS C:\WINDOWS\system32>

按说明安装离子

PS C:\WINDOWS\system32> npm install -g ionic cordova


  +-- request@2.51.0
  | `-- bl@0.9.5
  |   `-- readable-stream@1.0.34
  |     `-- inherits@2.0.3
  `-- unzip@0.1.9
    +-- fstream@0.1.31
    | +-- graceful-fs@3.0.11
    | | `-- natives@1.1.0
    | +-- inherits@2.0.3
    | `-- rimraf@2.5.4
    |   `-- glob@7.1.1
    |     +-- inflight@1.0.6
    |     +-- once@1.4.0
    |     `-- path-is-absolute@1.0.1
    +-- readable-stream@1.0.34
    | `-- inherits@2.0.3
    `-- setimmediate@1.0.5

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\developer\\AppData
\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "ionic" "cord
ova"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! path C:\Users\developer\AppData\Roaming\npm\node_modules\.staging\abbrev-
2a0e0d71
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename

npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\developer\AppD
ata\Roaming\npm\node_modules\.staging\abbrev-2a0e0d71' -> 'C:\Users\developer\AppD
ata\Roaming\npm\node_modules\cordova\node_modules\npm\node_modules\abbrev'
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\developer\AppD
ata\Roaming\npm\node_modules\.staging\abbrev-2a0e0d71' -> 'C:\Users\developer\AppD
ata\Roaming\npm\node_modules\cordova\node_modules\npm\node_modules\abbrev'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     C:\WINDOWS\system32\npm-debug.log
PS C:\WINDOWS\system32>

正确的方法是什么?

Ubuntu 12.04上的类似问题here

更新: - 我尝试将其作为管理员运行,但最终结果与稍有不同的错误消息相同。

C:\WINDOWS\system32> npm install -g ionic cordova

    |       `-- strip-json-comments@1.0.4
    +-- repeating@1.1.3
    | `-- is-finite@1.0.2
    |   `-- number-is-nan@1.0.1
    +-- semver-diff@2.1.0
    `-- string-length@1.0.1

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "ionic" "cordova"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! path C:\Users\developer\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\.cordova-lib.DELETE\node_modules\cordova-js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename

npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\developer\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\.cordova-lib.DELETE\node_modules\cordova-js' -> 'C:\Users\developer\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\cordova-lib\node_modules\cordova-js'
npm ERR!     at C:\Program Files\nodejs\node_modules\npm\lib\install\action\finalize.js:64:7
npm ERR!     at C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\async-map.js:52:35
npm ERR!     at Array.forEach (native)
npm ERR!     at C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\async-map.js:52:11
npm ERR!     at Array.forEach (native)
npm ERR!     at asyncMap (C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\async-map.js:51:8)
npm ERR!     at moveModules (C:\Program Files\nodejs\node_modules\npm\lib\install\action\finalize.js:61:5)
npm ERR!     at C:\Program Files\nodejs\node_modules\npm\lib\install\action\finalize.js:56:70
npm ERR!     at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:48:26
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\developer\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\.cordova-lib.DELETE\node_modules\cordova-js' -> 'C:\Users\developer\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\cordova-lib\node_modules\cordova-js'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, rename 'C:\Users\developer\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\.cordova-lib.DELETE\node_modules\cordova-js' -> 'C:\Users\developer\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\cordova-lib\node_modules\cordova-js'
npm ERR!     at C:\Program Files\nodejs\node_modules\npm\lib\install\action\finalize.js:64:7
npm ERR!     at C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\async-map.js:52:35
npm ERR!     at Array.forEach (native)
npm ERR!     at C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\async-map.js:52:11
npm ERR!     at Array.forEach (native)
npm ERR!     at asyncMap (C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\async-map.js:51:8)
npm ERR!     at moveModules (C:\Program Files\nodejs\node_modules\npm\lib\install\action\finalize.js:61:5)
npm ERR!     at C:\Program Files\nodejs\node_modules\npm\lib\install\action\finalize.js:56:70
npm ERR!     at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:48:26
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\developer\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\.cordova-lib.DELETE\node_modules\cordova-js' -> 'C:\Users\developer\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\cordova-lib\node_modules\cordova-js'
npm ERR!     at Error (native) parent: 'ionic-app-lib' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\WINDOWS\system32\npm-debug.log

C:\WINDOWS\system32>

1 个答案:

答案 0 :(得分:0)

查看其他SO帖子和资源中的不同建议。

常见建议

  1. 删除C:\Users\developer\AppData\Roaming\npm文件夹并手动创建npm并运行为Administrator

  2. 通过npm install -g npm再次安装npm并运行为Administrator

  3. 为npm

  4. 创建不同的文件夹

    真正有效的是#3 - 即将npm文件夹从默认的npm安装程序选项更改为用户创建的其他目录。

    <强>步骤

    1. 检查当前的npm路径

      C:\>npm config get prefix

      C:\Users\developer\AppData\Roaming\npm
      C:\>

    2. 将npm和npm-cache文件夹设置为某个用户创建的目录

      C:\>npm config set prefix C:\dev\npm_repo\npm --global

      C:\>npm config set cache C:\dev\npm_repo\npm-cache --global

    3. 运行npm install -g <some_module>以测试模块是否已安装在目录C:\dev\npm_repo\npm

    4. 从命令提示符处以npm install -g ionic cordova

    5. 运行Administrator
    6. 将路径C:\dev\npm_repo\npm添加到PATH环境变量

    7. 注意: -

      在第3步中,我以普通用户身份运行npm install -g jshintjshint安装正常。但是,以普通用户身份运行npm install -g ionic cordova仍然会出现如下错误。因此,在离子步骤4中,安装运行为Administrator

      npm ERR! Windows_NT 10.0.10586
      npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "ionic" "cordova"
      npm ERR! node v6.9.1
      npm ERR! npm  v3.10.8
      npm ERR! path C:\dev\npm_repo\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\cordova-lib\node_modules\npm\node_modules\node-gyp
      npm ERR! code EPERM
      npm ERR! errno -4048
      npm ERR! syscall rename
      
      npm ERR! Error: EPERM: operation not permitted, rename 'C:\dev\npm_repo\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\cordova-lib\node_modules\npm\node_modules\node-gyp' -> 'C:\dev\npm_repo\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\cordova-lib\node_modules\npm\node_modules\.node-gyp.DELETE'
      npm ERR!     at moveAway (C:\Program Files\nodejs\node_modules\npm\lib\install\action\finalize.js:38:5)
      npm ERR!     at destStatted (C:\Program Files\nodejs\node_modules\npm\lib\install\action\finalize.js:27:7)
      npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
      

      npm install -g ionic cordova作为Administrator

      运行的最终结果
      C:\WINDOWS\system32>npm install -g ionic cordova
      C:\dev\npm_repo\npm\cordova -> C:\dev\npm_repo\npm\node_modules\cordova\bin\cordova
      C:\dev\npm_repo\npm\ionic -> C:\dev\npm_repo\npm\node_modules\ionic\bin\ionic
      C:\dev\npm_repo\npm
      +-- cordova@6.4.0
      | +-- cordova-lib@6.4.0
      | +-- insight@0.8.3
      | +-- nopt@3.0.1
      | `-- update-notifier@0.5.0
      `-- ionic@2.1.4
        +-- @ionic/app-generators@0.0.3
        +-- cli-table@0.3.1
        +-- expand-tilde@1.2.0
        +-- gulp@3.8.8
        +-- gulp-util@3.0.7
        | `-- dateformat@1.0.12
        |   `-- meow@3.7.0
        |     +-- normalize-package-data@2.3.5
        |     `-- read-pkg-up@1.0.1
        |       `-- read-pkg@1.1.0
        +-- inquirer@0.11.2
        +-- ionic-app-lib@2.1.2
        | +-- cordova-lib@6.1.0
        | | +-- cordova-common@1.1.1
        | | | `-- osenv@0.1.3
        | | |   +-- os-homedir@1.0.1
      
      ## snipped ##
      
          +-- match-stream@0.0.2
          | `-- buffers@0.1.1
          +-- pullstream@0.4.1
          | +-- over@0.0.5
          | `-- slice-stream@1.0.0
          +-- readable-stream@1.0.34
          | +-- core-util-is@1.0.2
          | +-- inherits@2.0.3
          | +-- isarray@0.0.1
          | `-- string_decoder@0.10.31
          `-- setimmediate@1.0.5
      
      
      C:\WINDOWS\system32>
      
      C:\Windows\System32>ionic -v
      2.1.4
      
      
      C:\Windows\System32>cordova -v
      6.4.0
      
      C:\Windows\System32>