Vue-Cli won't install - node.js

I have node 11.2.0
Keep receiving this error.
Andrews-MacBook-Pro:vueTutorial aharris$ npm install -g #vue/cli
npm WARN deprecated hoek#5.0.4: This version is no longer maintained. Please upgrade to the latest version.
npm WARN deprecated cross-spawn-async#2.2.5: cross-spawn no longer requires a build toolchain, use it instead
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm WARN #apollographql/apollo-upload-server#5.0.3 requires a peer of graphql#^0.13.1 but none is installed. You must install peer dependencies yourself.
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/aharris/.npm/_logs/2018-11-25T18_43_42_502Z-debug.log

You are facing the problem of file permissions.
-g parameter of npm means "globally", which will install those file in the system directory, specifically in your computer /usr/local/lib/node_modules, where the owner is possibly root and with permission rwxr-xr-x, means those who is not root will have no permission to write.
Then, you may use sudo to get this permission, or just like NPM modules won't install globally without sudo said, set the npm prefix into the path where you have permissions:
$ npm config set prefix '~/.npm-packages'

All you need to do is run the same command with sudo before it,
sudo npm install -g #vue/cli
and you'll be prompted for the admin password.

Related

Why can't I install anything with Node on my Mac OS Catalina

I've needed to install a number of things with node but ever since I updated my system to Catalina I just get errors that I'm assuming are due to the new security measures on Mac.
The last thing I tried to install was this command:
npm install -g gulp gulp-cli browser-sync
I got this error
npm WARN deprecated resolve-url#0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
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! 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!
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/jessiematias/.npm/_logs/2020-03-31T15_45_46_951Z-debug.log
How can I ensure I don't get these errors anymore whenever I try to install something on the command line? It's saying to try running the commmand again as root/Administrator. How do I do that?

Npm client looks like updated but does not update

[grexlin85:~] >sudo npm i -g npm#latest
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
+ npm#6.13.7
updated 1 package in 5.748s
[grexlin85:~] >npm -v
5.8.0
[grexlin85:~] >sudo npm -v
6.13.7
Hello, I've updated my npm but if I write sudo npm -v it looks like updated but does not update and the version is still same. What can I do?
--------Edit-------
[grexlin85:~] >npm i -g npm#latest
npm WARN npm npm does not support Node.js v10.15.2
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
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 ERR! path /usr/local/lib/node_modules/npm
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'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules/npm\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules/npm' }
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! /home/grexlin85/.npm/_logs/2020-02-03T07_50_54_366Z-debug.log
I've tried without sudo and i get this output

Errors while installing AWS Amplify CLI

Tried installing the CLI with the command given on the official website, this is the response :
npm install -g #aws-amplify/cli
npm WARN deprecated #types/ora#3.2.0: This is a stub types definition. ora provides its own type definitions, so you do not need this installed.
npm WARN deprecated node-uuid#1.4.8: Use uuid module instead
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm WARN #conduitvc/mosca#2.8.3 requires a peer of leveldown#~1.4.3 but none is installed. You must install peer dependencies yourself.
npm WARN #conduitvc/mosca#2.8.3 requires a peer of ioredis#^1.15.1 but none is installed. You must install peer dependencies yourself.
npm WARN #conduitvc/mosca#2.8.3 requires a peer of mongodb#~2.1.4 but none is installed. You must install peer dependencies yourself.
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 have installed the latest versions of node and npm. Fixing this would be really helpful. TIA
In my case, I just had to add sudo in front of my command line request on my Mac Command Line:
sudo npm install -g #aws-amplify/cli
I was having the same issue. What worked for me was:
npm uninstall -g #aws-amplify/cli
npm install -g #aws-amplify/cli
Make sure your PC is connected to internet connection during all of this. If possible don't minimize the window, wait until everything is properly installed.
Read a blogpost on this similar error and that author suggests to install typescript, which would fix the problem. Followed that advice, installed typescript and installed aws cli and voila! it worked!. No idea how, but it fixed my problem. Curious to know how, if anyone is aware of this please let me know in your answer. TIA
sudo chown -R $USER:$(id -gn $USER) /Users/user_name/.config

Gulp installation permission issue

I want to install Gulp 4.0.2 on Mac but it fails due to missing write access.
$ npm i -S gulp -g
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).
Seems Gulp installation requires root privileges but it is not recommended. I don't want to install gulp as administrator :(
Is it possible to create another user w/o root privileges and install Gulp from there? If yes, how to do that?
Any advice will be appreciated, thanks!
You can install gulp local to your project directory rather than globally:
npm install gulp
You can then run the local version using npx:
npx gulp
Note: npx comes bundled with NPM version 5.2+
You could also use a script in your package.json:
"scripts": {
"gulp": "gulp"
}
npm run gulp
Official docs to avoid these permission issues...
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
Be sure to try touch ~/.zshrc if you're on a newer mac.

error while installing "npm install -g ionic cordova"

When I install npm install -g ionic cordova It throws below error
npm WARN checkPermissions Missing write access to
/usr/lib/node_modules npm ERR! path /usr/lib/node_modules npm ERR!
code EACCES npm ERR! errno -13 npm ERR! syscall access npm ERR! Error:
EACCES: permission denied, access '/usr/lib/node_modules' npm ERR! {
Error: EACCES: permission denied, access '/usr/lib/node_modules' npm
ERR! stack: 'Error: EACCES: permission denied, access
\'/usr/lib/node_modules\'', npm ERR! errno: -13, npm ERR! code:
'EACCES', npm ERR! syscall: 'access', npm ERR! path:
'/usr/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!
/home/javauser/.npm/_logs/2018-05-19T04_42_24_737Z-debug.log
I tried with root user as well.
I am using node v9.11.1 , npm 6.0.1
Never use npm with sudo (or as root)! You can create potential backdoor to your system.
I have just answered a very similar question in the following link: How to fix the problem with vue.js instalation
Basicaly what is happening is that NPM does not have the privileges to access /usr/local/lib. To give it access, you could change the ownership of ~/.npm in order to belong to your current user. This could be this way:
sudo chown -R $(whoami) ~/.npm
This way you do not have to run npm as sudo, which is not recomended. I believe that it is due to vulnerabilities that are known in npm packages.
Here is an article about it: Don't use "sudo" with npm "install"
run with sudo in Mac OS or linux
sudo npm install -g ionic cordova
or in windows open cmd with run as administrator
npm install -g ionic cordova

Resources