How to get npm or sass to install globally? - node.js

I've been watching tutorials and searching all over, and I've seen several similar issues on here. But none with the same errors. So I apologize if this has been answered before.
I'm taking a self-paced coding class. And I'm supposed to install sass. I finally found a tutorial that seemed straightforward. But when I entered the commands I'm getting error codes in my terminal. I'm very new to all this, so I have no idea what any of this means.
Some context: I downloaded homebrew, but didn't understand that either (so I uninstalled it). So then I Followed THIS tutorial where I downloaded node.js/npm. And everything went fine until I tried the install -g sass command. Then I started getting all these messages and going down the rabbit hole. Npmjs.com has some info on this issue, but I couldn't figure it out. It mentions reinstalling npm, or using "nvm". But when I tried the command npm install -g npm it returned very similar errors.
carlosprieto#Carloss-Mac-mini ~ % npm install -g sass
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/sass
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/sass'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/sass'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/sass'
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! /Users/carlosprieto/.npm/_logs/2022-06-17T16_02_28_018Z-debug-0.log

you need admin access, using sudo should help you
sudo npm i -g sass
this means you have superuser access, and is required to install packages globally.
read more here: https://www.tutorialspoint.com/unix_commands/sudo.htm

Related

EACCES error every time I try and do something with npm

Whenever I do anything related to npm, including uninstalling npm itself, I get this error:
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/bin/corepack
npm ERR! dest /usr/local/bin/.corepack-0KY6b4OJ
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/bin/corepack' -> '/usr/local/bin/.corepack-0KY6b4OJ'
npm ERR! [Error: EACCES: permission denied, rename '/usr/local/bin/corepack' -> '/usr/local/bin/.corepack-0KY6b4OJ'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/bin/corepack',
npm ERR! dest: '/usr/local/bin/.corepack-0KY6b4OJ'
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.
This didn't use to be the case as I have had no issues in the past, although the last time I tried to use an npm-related command was about a year ago.
I've tried many solutions, including sudo, nvm and uninstalling Node completely but nothing seems to work. I haven't used Node much before so I'm not very familiar with it unfortunately, so any help would be greatly appreciated.
run npm package as administrator by using the command
sudo npm install -g npm#latest
Turns out it was an issue with my antivirus software! After disabling the software and installing NVM everything now works fine.

npm ERR! Error: EACCES: permission denied

I'm having this famous issue while trying to install Typescript in my react app. Concretely, I am running this: npm install --save typescript #types/node #types/react #types/react-dom #types/jest
and I am getting this response:
npm ERR! code EACCES npm ERR! syscall rename npm ERR! path
/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node npm ERR!
dest
/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/.node-8MzkXP42
npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, rename
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node' ->
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/.node-8MzkXP42'
npm ERR! [Error: EACCES: permission denied, rename
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node' ->
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/.node-8MzkXP42']
{ npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR!
syscall: 'rename', npm ERR! path:
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node', npm
ERR! dest:
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/.node-8MzkXP42'
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/asier/.npm/_logs/2021-04-29T10_48_16_436Z-debug.log
I've checked the ownership of that folder: ls -l/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node, and I am the owner of all the files.
I've also tried to install it executing npm set unsafe-perm true
but didn't work.
I've installed npm and node with NVM and I am using Windows 10 with
Ubuntu on WSL.
npm -v: 7.11.1
node -v: v15.14.0
nvm --version: 0.34.0
The weird thing is that I can install other packages with no issues, I just installed react-hook-form for example.
I don't really know which can be the issue and I would be very happy if you guys can give me a clue!
Thank you beforehand for the help! :)
As I saw an error is related to permission. So you need to execute the command with the help of "sudo" like,
sudo npm install --save typescript #types/node #types/react #types/react-dom #types/jest
I had the same problem and the way to fix it was to stop my code that was running (webpack serve). In Windows you can't edit/delete files when those are in use. I think wsl may behave the same as it is a linux subsystem "inside" Windows.

Npm EACCESS error when installing Firebase

I used to be able to run and deploy my code using firebase. I then upgraded to the new m1 MacBook pro. I git cloned my code and made some minor changes. I tried using
firebase deploy
but I got the error message
zsh: command not found: firebase
then I tried
npm install -g firebase-tools
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
npm WARN deprecated debug#4.1.0: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/firebase-tools/lib/bin/firebase.js
npm ERR! dest /usr/local/bin/firebase
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/firebase-tools/lib/bin/firebase.js' -> '/usr/local/bin/firebase'
npm ERR! [OperationalError: EACCES: permission denied, symlink '../lib/node_modules/firebase-tools/lib/bin/firebase.js' -> '/usr/local/bin/firebase'] {
npm ERR! cause: [Error: EACCES: permission denied, symlink '../lib/node_modules/firebase-tools/lib/bin/firebase.js' -> '/usr/local/bin/firebase'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/firebase-tools/lib/bin/firebase.js',
npm ERR! dest: '/usr/local/bin/firebase'
npm ERR! },
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/firebase-tools/lib/bin/firebase.js',
npm ERR! dest: '/usr/local/bin/firebase'
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! /Users/brennanadams/.npm/_logs/2020-12-03T18_52_42_463Z-debug.log
I looked this up on the internet but I have yet to find a solution, any help is appreciated. I am not sure if this is because I have the m1 chip and it not compatible or if a bunch of my settings reset when I upgraded. Thank you for help.
To install an npm package globally on Mac, try running with the sudo command. You'll need to enter your password.
sudo npm install -g firebase-tools
EDIT: Original title for this question asked about the request deprecation which is why I spend a paragraph explaining that's not the real problem before getting to what the real issue is and what needs to be done.
Regarding request: You don't need to do anything about that. request will continue working just fine as a dependency of firebase. Hopefully, they will replace it with something else at some point, but there's no issue to address. The deprecation of the request module was done as a proactive measure to push people to more actively-maintained and modern solutions. It wasn't because there's something fundamentally broken with request that requires people to move to something else now now now or anything like that.
Instead, your problem here is the EACCESS issue. For that, you'll want to review the npm documentation on that problem. The upshot is you probably want to reinstall Node.js with a version manager such as nvm. If you can't or don't want to do that, you can configure npm to install global packages in a directory that you have write permission to.
It worked with Yarn, Try:
yarn global add firebase-tools
export PATH="$(yarn global bin):$PATH"
command -v firebase
and firebase login will work normally

How to fix permission error while installing Parcel Bundler with terminal

while installing parcel module in nodeJS, via terminal on Mac OS i am getting permission error.
error: checkPermission Missing write access to /usr/local/lib/node_modules
i am new at learning Node Modules. i tried installing(Node , NPM) everything works perfect. but first time installing node module it throwing error. i know its looking for directory of Windows type URL but i don't know how to fix it for mac.
iMac:~ hassan$ node -v
v11.10.0
iMac:~ hassan$ npm -v
6.7.0
iMac:~ hassan$ npm install -g parcel-bundler
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:
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).
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/hassan/.npm/_logs/2019-04-23T13_13_46_848Z-debug.log
i want to install Parcel Bundler for Ui animation on my website.
You'll need to have access to /usr/local/lib/node_modules as a super-admin has, to perform the global installation of parcel-bundler.
As mentionned in the comment and assuming your user is the list of sudoers for this computer, you can simply do :
sudo npm -g install parcel-bundler
If this is not the case, you'll need more permissions on the system to install Parcel. Then you'll be able to :
Add your user as a sudoers in the file sudoers.d (Be careful doing this ! See this tutorial for OSX).
Perform the operation directly as the super-admin of the computer.
I'd prefer the 1st option regarding the long-term administration and security of the computer itself. The other option, while not recommended, is still possible for some cases.
Otherwise, you'll not have permission errors if you choose to install Parcel locally. In this case, just omit the -g flag while running the command (i.e npm install parcel-bundler). It will end up by adding parcel to your package.json file so that you'll be able to install it again later.

Error installing Gulp

I am pretty new to using terminal and installing gulp, but I am running through a few errors. Errors keep popping up and I am not sure why. My goal for right now is to install gulp globally, but not sure if any old files are interfering. Maybe a clean out and reinstall would work? Error is below. Thanks!
pm ERR! tar.unpack untar error /Users/.npm/gulp/3.9.0/package.tgz
npm ERR! Darwin 14.1.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "gulp"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! path /usr/local/lib/node_modules/gulp
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/gulp'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/gulp']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/gulp',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/gulp',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR! 'FSReqWrap.oncomplete (fs.js:95:15)' ] }
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! /usr/local/bin/npm-debug.log
Other answers are bypassing these issues by the use of sudo or su root. I personally don't recommend this. The reason it works is because on OSX the global npm module directory has stricter permissions. Running your commands with root privileges just to get around permissions issues is likely only going to cause you headaches down the road and open you up to security vulnerabilities. At the very least it's going to cause you to have to use sudo constantly when trying to do routine node/npm things. The safer way would be to change the permissions of just that directory. However, even that can sometimes cause nightmares.
My alternative recommendation to the other suggestions here is to use nvm.
You can install it with curl (you have this already, just paste the below command):
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash
Or you can use Homebrew if you have that installed:
brew install nvm
Once installed, you'll be able to easily install any node or iojs version that you want.
nvm install node
The above command will install the latest version of node. The nice part is that all your node/iojs installations are managed within ~/.nvm/, meaning they are inside your home directory where you'll always have full access permissions and won't ever need to use sudo.
You dont have the rights to write un /sur/local
Either you run sudo npm install -g gulp or give your user the rights to write in /usr/local

Resources