Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESlint Error Install from Command Line

I get the following error installing 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 --init to run to create the .eslintrc file

like image 554
wqu Avatar asked Apr 26 '16 10:04

wqu


People also ask

How do I fix ESLint error?

There are three ways that ESLint fix can be run: eslint --fix. eslint --fix-dry-run. eslint --fix --fix-type.

Which of the following command is used to install ESLint using npm?

Note: npm init @eslint/config assumes you have a package. json file already. If you don't, make sure to run npm init or yarn init beforehand. It is also possible to install ESLint globally rather than locally (using npm install eslint --global ).

How do I install ESLint locally?

If you haven't installed ESLint either locally or globally do so by running npm install eslint in the workspace folder for a local install or npm install -g eslint for a global install. On new folders you might also need to create a . eslintrc configuration file.


3 Answers

It looks like you're trying to install globally while your user doesn't have access to the global node_modules folder. You can try installing it as root or chown '/usr/local/lib/node_modules'.

Install as 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.

Edit: Try the solution in the answer here "Permission Denied" when trying to install ESlint on OSX globally

Add this to ~/.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.

like image 105
rajatppn Avatar answered Oct 13 '22 04:10

rajatppn


If you're getting eslint: command not found try:

./node_modules/.bin/eslint --init
like image 29
Nelu Avatar answered Oct 13 '22 05:10

Nelu


Try

npm install eslint --save-dev and then eslint --init.

Let me know if you face any issues.

like image 5
Raja Sekar Avatar answered Oct 13 '22 05:10

Raja Sekar