npm install -g #sanity/cli commend is not working - npm

I tried to run npm install -g #sanity/cli commend to use Sanity but my return is this..
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/#sanity/cli/bin/sanity
npm ERR! dest /usr/local/bin/sanity
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/#sanity/cli/bin/sanity' -> '/usr/local/bin/sanity'
npm ERR! [Error: EACCES: permission denied, symlink '../lib/node_modules/#sanity/cli/bin/sanity' -> '/usr/local/bin/sanity'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/#sanity/cli/bin/sanity',
npm ERR! dest: '/usr/local/bin/sanity'
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/kevinsong/.npm/_logs/2022-07-27T17_49_06_969Z-debug-0.log
npm -v 8.13.2
What need to be done to run the npm install -g #sanity/cli?
when I do vi /usr/local/bin, I see this
node*
corepack# --> /usr/local/lib/node_modules/corepack/dist/corepack.js
npm# --> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npx# --> /usr/local/lib/node_modules/npm/bin/npx-cli.js
~

It's because your current user doesn't have the permission
you can check the permission
ls -la /usr/local/lib/node_modules
get the permission for sudo access
sudo chown -R $USER /usr/local/lib/node_modules/
Now try with
sudo npm install -g #sanity/cli
Click HERE for more

Related

VS code setting up development tools ERR! permission

I'm new to using VS code, I'm trying to install Hubspot tools using the npm install -g #hubspot/cli
But when i do i get the following
Thorins-MBP:Practice project thorinphoenix$ npm install -g #hubspot/cli
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/#hubspot
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/#hubspot'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/#hubspot'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/#hubspot'
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/thorinphoenix/.npm/_logs/2022-05-18T13_17_18_580Z-debug-0.log
Thorins-MBP:Practice project thorinphoenix$
I used the best fix on this page and it worked. How to fix EACCES issues with npm install
Enter this into terminal:
sudo chown -R `whoami` ~/.npm
sudo chown -R `whoami` /usr/local/lib/node_modules

Can't install json-server

I am trying to install JSON-Server, but it's not working!
I have used the following command: npm install -g json-server
Here is the error message:
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/json-server
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/json-server'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/json-server'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/json-server'
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.
Try to use sudo before command :
sudo npm install -g json-server

Why I am facing error while installing Nodemon?

Last login: Sun Sep 19 13:02:00 on ttys000
navarajgiri#Navarajs-MacBook-Pro ~ % npm i nodemon
added 120 packages, and audited 121 packages in 708ms
11 packages are looking for funding
run npm fund for details
found 0 vulnerabilities
navarajgiri#Navarajs-MacBook-Pro ~ % npm install -g nodemon
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/nodemon
npm ERR! dest /usr/local/lib/node_modules/.nodemon-SfftGed4
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/nodemon' -> '/usr/local/lib/node_modules/.nodemon-SfftGed4'
npm ERR! [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/nodemon' -> '/usr/local/lib/node_modules/.nodemon-SfftGed4'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/nodemon',
npm ERR! dest: '/usr/local/lib/node_modules/.nodemon-SfftGed4'
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/navarajgiri/.npm/_logs/2021-09-19T04_04_27_310Z-debug.log
navarajgiri#Navarajs-MacBook-Pro ~ %
You use npm with the -g (global mode) option which implies system-wide install, and this requires permission (EACCESS) to do so. Either install it in local mode (without -g) possible in a virtuaelenv or run the command as root (via sudo}) as suggested.

How to install expo cli correctly?

I am trying to install expo cli globally but I am getting errors:
OS: Catalina 10.15.4
Node: 14.6
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! /Users/mac/.npm/_logs/2020-07-25T10_36_46_119Z-debug.log
I install in the Visual Studio terminal, I also tried to install through the console, but the result did not change
When installing some packages globally, you need to do so as a privileged user. On Mac, use sudo to elevate the installation command. E.g. sudo npm install your-package -g

NPM local install tried to write ~/.npm folder which got EACCESS error

I tried to add the 'method-override' package to my current Express project. I ran below command, and got error.
qinguo$ npm install method-override --save
npm WARN package.json redis-url#0.2.0 No repository field.
npm ERR! Error: EACCES, mkdir '/Users/qinguo/.npm/parseurl/1.1.3'
npm ERR! { [Error: EACCES, mkdir '/Users/qinguo/.npm/parseurl/1.1.3']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/qinguo/.npm/parseurl/1.1.3',
npm ERR! parent: 'method-override' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 13.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "method-override" "--save"
npm ERR! cwd /Users/qinguo/allcodes/gitebay/NewX/sh-go
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.5.0-alpha-3
npm ERR! path /Users/qinguo/.npm/parseurl/1.1.3
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/Users/qinguo/.npm/parseurl/1.1.3'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/qinguo/allcodes/gitebay/NewX/sh-go/npm-debug.log
npm ERR! not ok code 0
I tried to update npm, re-install, it didn't work.
Try running as sudo -
npm install method-override --save
My guess is that root owns some of the packages in npm's cache. You can check by running:
ls -l ~/.npm
Check if the package causing the error is not owned by your user.
If some of the packages are owned by root, you should chown the ~/.npm folder to your current user.
sudo chown -R `whoami` ~/.npm
Read more: npm cache