科尔多瓦:无法添加Android平台

时间:2018-02-21 23:56:30

标签: node.js cordova ionic-framework npm npm-install

我刚刚使用" sidemenu"生成了一个新的Ionic1应用程序。模板。 没有添加插件,没有额外的依赖。

我收到错误:

npm ERR! path C:\myApp\node_modules\.staging\cordova-android-dbc95b4b\node_modules\brace-expansion
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'C:\myApp\node_modules\.staging\cordova-android-dbc95b4b\node_modules\brace-expansion' -> 'C:\myApp\node_modules\.staging\brace-expansion-7416809b'
npm ERR!  { Error: EPERM: operation not permitted, rename 'C:\myApp\node_modules\.staging\cordova-android-dbc95b4b\node_modules\brace-expansion' -> 'C:\myApp\node_modules\.staging\brace-expansion-7416809b'
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, rename 'C:\myApp\node_modules\.staging\cordova-android-dbc95b4b\node_modules\brace-expansion' -> 'C:\myApp\node_modules\.staging\brace-expansion-7416809b'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'rename',
npm ERR!      path: 'C:\\nodejs\\fuckit\\node_modules\\.staging\\cordova-android-dbc95b4b\\node_modules\\brace-expansion',
npm ERR!      dest: 'C:\\nodejs\\fuckit\\node_modules\\.staging\\brace-expansion-7416809b' },
npm ERR!   stack: 'Error: EPERM: operation not permitted, rename \'C:\\nodejs\\fuckit\\node_modules\\.staging\\cordova-android-dbc95b4b\\node_modules\\brace-expansion\' -> \'C:\\nodejs\\fuckit\\node_modules\\.staging\\brace-expansion-7416809b\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\nodejs\\fuckit\\node_modules\\.staging\\cordova-android-dbc95b4b\\node_modules\\brace-expansion',
npm ERR!   dest: 'C:\\nodejs\\fuckit\\node_modules\\.staging\\brace-expansion-7416809b',
npm ERR!   parent: 'fuckit' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

我在以管理员身份运行的powershell上。

node 8.9.4
npm 5.1.0
cordova 8.0.0
ionic 3.19.1

已解决(?):作为其他4-5次我遇到这个问题,我解决但我不知道如何。我只是尝试重新安装节点(v8和v9),npm(不同版本),cordova(不同版本),nvm。完全浪费了大约15个小时后,我在第4次完全刷新node / npm环境时解决了。 NPM只是一个残酷的噩梦。

编辑:我怀疑我解决了,因为我从

更改了npm目录
%APPDATA%/npm

C:\Program Files\nodejs

使用命令

npm config set prefix "C:\Program Files\nodejs"

1 个答案:

答案 0 :(得分:0)

令人惊讶的是,npm's GitHub issues页面上有多张门票可以解决您的问题。此外,我的一个队友也遇到了同样的问题......所以,只需查看他们的问题页面或尝试其中一个建议的解决方案:

  • 将您的npm更新为较新版本
  • 关闭IDE,例如VSCodeVisual Studionpm install再次
  • 从任务管理器中杀死所有正在运行的节点实例,然后再次npm install
  • ...