【问题标题】:NPM multiple install errorsNPM 多次安装错误
【发布时间】:2018-11-02 23:14:44
【问题描述】:

当我尝试安装 npm 时,控制台会给出以下错误和警告:

npm WARN checkPermissions Missing write access to C:\Users\Aristophanes\node_modules\web3
npm WARN ajv-keywords@2.1.1 requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-react-app@2.1.0 requires a peer of babel-eslint@^7.2.3 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-react-app@2.1.0 requires a peer of eslint@^4.1.1 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-loader@1.9.0 requires a peer of eslint@>=1.6.0 <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-jsx-a11y@5.1.1 requires a peer of eslint@^2.10.2 || ^3 || ^4 but none is installed. You must install peer dependencies yourself.
npm WARN firebase-functions@2.1.0 requires a peer of firebase-admin@~6.0.0 but none is installed. You must install peer dependencies yourself.

npm ERR! path C:\Users\Aristophanes\node_modules\web3
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access 'C:\Users\Aristophanes\node_modules\web3'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Aristophanes\AppData\Roaming\npm-cache\_logs\2018-11-02T23_13_12_948Z-debug.log

有谁知道我该如何解决这个问题?谢谢。

【问题讨论】:

    标签: node.js npm npm-install node-gyp


    【解决方案1】:

    尝试删除C:\Users\Aristophanes\node_modules\web3 中的web3 文件夹以及项目目录中的node_modules 文件夹(如果存在)。希望对你有帮助:)

    【讨论】:

      【解决方案2】:

      有两种解决方案。

      **1. Reinstall npm with a Node version manager (recommended).**
      

      这是避免权限问题的最佳方法。有关更多信息,请参阅此链接 (https://docs.npmjs.com/getting-started/installing-node#using-a-version-manager-to-install-nodejs-and-npm) 在安装 Node 版本管理器之前,您无需删除当前版本的 npm 或 Node.js。

      **2. Change npm's default directory manually.**
      

      如果您不使用 Windows,可以使用以下步骤。

      To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, it will be a hidden directory on your home folder.
      
      Back-up your computer before you start.
      
      Make a directory for global installations:
      

      mkdir ~/.npm-global

      Configure npm to use the new directory path:
      

      npm 配置设置前缀 '~/.npm-global'

      Open or create a ~/.profile file and add this line:
      

      导出 PATH=~/.npm-global/bin:$PATH

      Back on the command line, update your system variables:
      

      来源 ~/.profile

      测试:不使用 sudo 全局下载包。

      npm install -g jshint

      您可以使用相应的 ENV 变量来代替步骤 2-4(例如,如果您不想修改 ~/.profile):

       NPM_CONFIG_PREFIX=~/.npm-global
      

      【讨论】:

      • Node 版本管理器是否允许您使用旧版本的 Node 或旧版本的 Node 模块?当我安装了 firebase-admin 6.11.2 时,我收到了同样的 Firebase 警告,它要求安装 firebase-admin 6.0.0。
      猜你喜欢
      • 2023-03-30
      • 2012-02-09
      • 2022-01-10
      • 2016-04-03
      • 1970-01-01
      • 2014-11-21
      • 2015-06-15
      • 2015-10-24
      相关资源
      最近更新 更多