[英]ESlint Error Install from Command Line
I get the following error installing eslint:安装 eslint 时出现以下错误:
npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "eslint"
npm ERR! node v5.5.0
npm ERR! npm v3.8.8
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Leviathan/lj/npm-debug.log
I have not been able to figure out how to install eslint and also get this line:我一直无法弄清楚如何安装 eslint 并得到这一行:
eslint --init to run to create the.eslintrc file eslint --init 运行以创建.eslintrc 文件
如果你得到eslint: command not found
试试:
./node_modules/.bin/eslint --init
It looks like you're trying to install globally while your user doesn't have access to the global node_modules folder.看起来您正在尝试全局安装,而您的用户无权访问全局 node_modules 文件夹。 You can try installing it as root or chown '/usr/local/lib/node_modules'.
您可以尝试将其安装为 root 或 chown '/usr/local/lib/node_modules'。
Install as root -以 root 身份安装 -
sudo npm install -g eslint
Chown -陈 -
chown user:group /usr/local/lib/node_modules
npm install -g eslint
You can also change permissions to /usr/local/lib/node_modules to allow your user access using chmod.您还可以将权限更改为 /usr/local/lib/node_modules 以允许您的用户使用 chmod 进行访问。
Edit: Try the solution in the answer here "Permission Denied" when trying to install ESlint on OSX globally编辑:尝试在 OSX 上全局安装 ESlint 时,尝试此处“Permission Denied”中的答案中的解决方案
Add this to ~/.npmrc:将此添加到 ~/.npmrc:
prefix = ${HOME}/.npm-packages https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md You also have to add ${HOME}/.npm-packages/.bin to your PATH so that your shell knows where to look up the globally installed scripts.前缀 = ${HOME}/.npm-packages https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md您还必须添加 ${HOME}/.npm-packages /.bin 到您的 PATH 以便您的 shell 知道在哪里查找全局安装的脚本。
Try尝试
npm install eslint --save-dev
and then eslint --init
. npm install eslint --save-dev
然后eslint --init
。
Let me know if you face any issues.如果您遇到任何问题,请告诉我。
I've had eslint-bash permission denied, command not found
too.我
eslint-bash permission denied, command not found
。 For me the solution was :对我来说,解决方案是:
1. find the install path of eslint, for me it is: 1.找到eslint的安装路径,对我来说是:
# npm install -g eslint /root/mynode/node-v10.9.0-linux-x64/bin/eslint -> /root/mynode/node-v10.9.0-linux-x64/lib/node_modules/eslint/bin/eslint.js + eslint@5.6.0 updated 1 package in 5.114s
The path is /root/mynode/node-v10.9.0-linux-x64/lib/node_modules/eslint/bin/eslint.js
# npm install -g eslint /root/mynode/node-v10.9.0-linux-x64/bin/eslint -> /root/mynode/node-v10.9.0-linux-x64/lib/node_modules/eslint/bin/eslint.js + eslint@5.6.0 updated 1 package in 5.114s
路径为/root/mynode/node-v10.9.0-linux-x64/lib/node_modules/eslint/bin/eslint.js
2.run /root/mynode/node-v10.9.0-linux-x64/lib/node_modules/eslint/bin/eslint.js --init
2.
/root/mynode/node-v10.9.0-linux-x64/lib/node_modules/eslint/bin/eslint.js --init
Success!成功!
May be updating the dependencies to their latest versions (including major version changes) in the package.json file.可能会在 package.json 文件中将依赖项更新为最新版本(包括主要版本更改)。 would save you time.
会节省你的时间。
npx npm-check-updates -u
or you may have to install eslint globally.或者您可能必须全局安装 eslint。
npm i eslint -g
and after removing node modules of your current project并在删除当前项目的节点模块后
eslint --init
For: Zsh: command not found: eslint
对于:
Zsh: command not found: eslint
npm install eslint-plugin-react-hooks --save --dev
then run:然后运行:
npm install -g eslint
It should work它应该工作
运行一般更新以升级所有过时的软件包运行npm outdated
以查看更新的软件包,然后运行npm update
也npm-check-updates
和npm install
完成,您的错误可能会得到修复
eslint --init to run to create the .eslintrc file
is says create .eslintrc, you probably forgot to include .
eslint --init to run to create the .eslintrc file
是说创建 .eslintrc,您可能忘记包含 .eslintrc 文件.
before eslintrc在 eslintrc 之前
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.