【问题标题】:npm install -g @vue/cli VUE CLI INSTALL ERRORnpm install -g @vue/cli VUE CLI安装错误
【发布时间】:2021-02-13 06:46:36
【问题描述】:

我只是想安装 Vue CLI,但出现了这个错误。我有最新版本的 node.js,如下所示。我尝试了一些不同的方法,例如npm uninstall -g vue-clinpm cache clean --force。但他们没有工作。我该如何解决?

我的 npm 版本是 7.0.3。

C:\Users\HALİL_MONSTER>NODE
Welcome to Node.js v15.0.1.
Type ".help" for more information.

C:\Users\HALİL_MONSTER>npm install -g @vue/cli
npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path C:\Users\HALİL_MONSTER\AppData\Roaming\npm\node_modules\@vue\cli
npm ERR! dest C:\Users\HALİL_MONSTER\AppData\Roaming\npm\node_modules\@vue\.cli-P415H8gb
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\HALİL_MONSTER\AppData\Roaming\npm\node_modules\@vue\cli' -> 'C:\Users\HALİL_MONSTER\AppData\Roaming\npm\node_modules\@vue\.cli-P415H8gb'
npm ERR!  [Error: EPERM: operation not permitted, rename 'C:\Users\HALİL_MONSTER\AppData\Roaming\npm\node_modules\@vue\cli' -> 'C:\Users\HALİL_MONSTER\AppData\Roaming\npm\node_modules\@vue\.cli-P415H8gb'] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\HALİL_MONSTER\\AppData\\Roaming\\npm\\node_modules\\@vue\\cli',
npm ERR!   dest: 'C:\\Users\\HALİL_MONSTER\\AppData\\Roaming\\npm\\node_modules\\@vue\\.cli-P415H8gb'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\HALİL_MONSTER\AppData\Local\npm-cache\_logs\2020-10-30T19_06_23_457Z-debug.log

【问题讨论】:

  • 试试npm install -g @vue/cli --unsafe-perm

标签: node.js vue.js npm-install vue-cli


【解决方案1】:

我使用的是 Windows 7 和 nodejs 13。我遇到了同样的问题。我试过重新启动我的电脑,添加标志等。没有任何效果。 最后我用 yarn 解决了。

  1. 使用 npm 安装纱线:npm install --global yarn
  2. 使用yarn安装vue cli:yarn global add @vue/cli
  3. 配置 vue cli 安装的系统路径。 yarn 不会在目录中安装 vue cli 作为 npm

【讨论】:

    【解决方案2】:

    我在终端中下载 Vue 时遇到了同样的问题。 我通过使用解决了这个问题:

    sudo npm install -g @vue/cli
    

    然后我检查它是否安装正确并且是最新的:

    vue --version
    

    【讨论】:

    • 我试过了,但一开始没有用。然后我重新安装 Windows 并再次尝试它的工作。