I couldn't install npm on my mac. I got the following errors - npm-install

I am getting following checkPermissions error related write access while doing npm install.
npm install
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/tar/node_modules
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib
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/node_modules/tar/node_modules/minizlib'
npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mac/.npm/_logs/2018-02-08T17_10_28_286Z-debug.log .
Please provide some reference or information.

Use sudo in front of your install command and enter your password when prompted. It installs NPM into the global space, which requires SUDO if you are not on the root account.
That is what this part of the error is telling you: "Please try running this command again as root/Administrator."

After you install npm, you will have issues with global packages.
Use this suggested way of resolving it. Better, secure & maintainable.
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
nano ~/.zprofile
# Add a line to add the new dir to path, eg:
# PATH="~/.npm-global/bin":$PATH
# export PATH
source ~/.zprofile
Ref: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

Related

Getting No such file or directory: 'ganache-cli' error

I installed ganache-cli using npm install -g ganache-cli, however I am running into a No such file or directory: 'ganache-cli error when trying to run it. When calling echo $PATH, I see ~/.npm-global/bin, which contains the ganache-cli file, so I am confused as to what the issue could be. Any help is greatly appreciated.
For reference, I am using zsh on MacOS.
ganache-cli is now deprecated. You might see the following npm-warning:
npm WARN deprecated ganache-cli#6.12.2: ganache-cli is now ganache; visit https://trfl.io/g7 for details
Use npm install -g ganache.
Use sudo npm install -g ganache if you get some error like this:
$ npm install -g ganache
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
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!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2022-06-23T12_37_16_476Z-debug.log

Missing write access when installing Vue CLI

For some reason I cannot run the vue cli and trying to reinstall using:
npm install -g #vue/cli
I get a string of
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/#vue/cli/node_modules/#apollographql/graphql-playground-html
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/#vue/cli/node_modules/#babel/core/node_modules/semver
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/#vue/cli/node_modules/#babel/helper-plugin-utils
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/#vue/cli/node_modules/#babel/parser
And then ending with
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules/#vue/cli/node_modules/#apollographql/graphql-playground-html
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/#vue/cli/node_modules/#apollographql/graphql-playground-html'
npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules/#vue/cli/node_modules/#apollographql/graphql-playground-html'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules/#vue/cli/node_modules/#apollographql/graphql-playground-html\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules/#vue/cli/node_modules/#apollographql/graphql-playground-html' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
I have tried changing the permissions of /usr/local/lib/node_modules and then changed the group to "staff" (which is the same as Python also in /lib. I don't think I can uninstall node without some serious problems everywhere I use that. Stuck and not sure how to install or get vue cli running.
I have just had the same issue, but solved it by adding "sudo" before it.
So, the new line would instead look like;
sudo npm install -g #vue/cli

npm install global not working on mac, Says I don't have permissions? Missing write access to /usr/local/lib/node_modules

I don't have permissions to my node modules files, It is not allowing me to install or update anything globally.
I know that using -sudo is not recommended for it can cause problems with permissions later. I thought I could update npm and node to solve the issue but I don't have permissions to do that.
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! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR! stack:
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! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
I ended up using this code and it's working now.
sudo chown -R $USER /usr/local/lib/node_modules

npm write access denied when trying to install netlify-lambda for stripe

This happens when I was trying to install netlify-lambda in a gatsby app
npm install -g netlify-lambda
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/netlify-lambda/node_modules/#babel/plugin-proposal-object-rest-spread
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/netlify-lambda/node_modules/#babel/parser
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/netlify-lambda/node_modules/#babel/helper-create-class-features-plugin
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/netlify-lambda/node_modules/#babel/types
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/netlify-lambda/node_modules/#babel/generator
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/netlify-lambda/node_modules/caniuse-lite
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/netlify-lambda/node_modules/duplexify/node_modules/readable-stream
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/netlify-lambda/node_modules/duplexify
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/netlify-lambda/node_modules/webpack
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/netlify-lambda/node_modules/#babel
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/netlify-lambda/node_modules
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/netlify-lambda/node_modules/duplexify/node_modules
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules/netlify-lambda/node_modules/#babel/plugin-proposal-object-rest-spread
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/netlify-lambda/node_modules/#babel/plugin-proposal-object-rest-spread'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules/netlify-lambda/node_modules/#babel/plugin-proposal-object-rest-spread']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules/netlify-lambda/node_modules/#babel/plugin-proposal-object-rest-spread\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path:
npm ERR! '/usr/local/lib/node_modules/netlify-lambda/node_modules/#babel/plugin-proposal-object-rest-spread' }
npm ERR!
Tried but not work:
sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config
sudo npm install -g netlify-lambda
reinstall npm
You don't have root access in the Netlify build container, so sudo won't do you any good.
You also shouldn't need to npm install anything manually like that - you should ship your package.json in the root of your repo and it should have the specifications for your packages set. Netlify then automatically runs npm install (see this article for more details), installs what you need, AND puts it on your $PATH so you can just run any binaries generated as a part of the installation.
This article describes the flow of our continuous deployment environment: https://www.netlify.com/blog/2016/10/18/how-our-build-bots-build-sites/
TL;DR You should effectively be able to put netlify-lambda into package.json as a dependency and then run it during build with no further installation needed.

Error when installing the express application generator

I recently installed node and express with the help of the mozilla tutorial. I am on the next step of installing the application generator, but when I run
npm install express-generator -g
in my terminal: I recieve the following errors:
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
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! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! stack: '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! A complete log of this run can be found in:
npm ERR! /Users/adamgusky/.npm/_logs/2018-02-17T20_26_53_688Z-debug.log
I've been googling this topic for an hour now and I am very new to using the terminal for web applications (this is for a school project), so any help is appreciated.
I had a similar issue. The problem is that you aren't an administrator so you can't write to that folder. However it's considered a BAD IDEA to run sudo npm install. So what you need to do is to change the default install folder for npm global installation to one where you do have write permission.
See npm's documentation: https://docs.npmjs.com/getting-started/fixing-npm-permissions.
And also see this useful article on github: https://github.com/nodeschool/discussions/wiki/Installing-global-node-modules-(Linux-and-Mac)