NPM多次安装错误

时间:2018-11-02 23:14:45

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

当我尝试安装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

有人知道我该如何解决吗?谢谢。

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

有2种解决方案。

arr

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

Object.setPrototypeOf

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

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

mkdir〜/ .npm-global

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

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

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:

export PATH =〜/ .npm-global / bin:$ PATH

Configure npm to use the new directory path:

源〜/ .profile

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

npm install -g jshint

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

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