简体   繁体   English

NPM多次安装错误

[英]NPM multiple install errors

When I try to install npm the console gives the following errors & warnings: 当我尝试安装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 

Does anyone know how I can fix this? 有谁知道我该如何解决? Thank you. 谢谢。

Try removing the web3 folder in C:\\Users\\Aristophanes\\node_modules\\web3 , as well as the node_modules folder in your project directory (if exists). 尝试删除web3文件夹C:\\Users\\Aristophanes\\node_modules\\web3 ,还有node_modules在项目目录文件夹(如果存在)。 Hope it will help you :) 希望它能对您有所帮助:)

There are 2 solutions for this. 有两种解决方案。

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

This is the best way to avoid permissions issues. 这是避免权限问题的最佳方法。 For more information, refer this link (https://docs.npmjs.com/getting-started/installing-node#using-a-version-manager-to-install-nodejs-and-npm) You do not need to remove your current version of npm or Node.js before installing a Node version manager. 有关更多信息,请参阅此链接(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.**

If you're not using windows you can use below steps. 如果您不使用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 mkdir〜/ .npm-global

Configure npm to use the new directory path:

npm config set prefix '~/.npm-global' npm config设置前缀'〜/ .npm-global'

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

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

Back on the command line, update your system variables:

source ~/.profile 来源〜/ .profile

Test: Download a package globally without using sudo. 测试:在不使用sudo的情况下全局下载软件包。

npm install -g jshint npm install -g jshint

Instead of steps 2-4, you can use the corresponding ENV variable (eg if you don't want to modify ~/.profile): 可以使用相应的ENV变量代替步骤2-4(例如,如果您不想修改〜/ .profile):

 NPM_CONFIG_PREFIX=~/.npm-global

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM