Can't install vue-cli because infinite loop of npm issues - node.js

Brand new to VueJS and am trying to install vue-cli as it is my understanding that it is the minimal requirement to build a VueJS application.
I run:
$ npm install --global vue-cli
Unhandled rejection Error: EACCES: permission denied, open '/Users/myuser/.npm/_cacache/tmp/2e41a7b1'
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
I found this SO answer here which recommends running:
$ npm i --no-package-lock
npm WARN saveError ENOENT: no such file or directory, open '/Users/myuser/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/myuser/package.json'
npm WARN myuser No description
npm WARN myuser No repository field.
npm WARN myuser No README data
npm WARN myuser No license field.
up to date in 0.374s
found 0 vulnerabilities
╭────────────────────────────────────────────────────────────────╮
│ │
│ New minor version of npm available! 6.9.0 → 6.14.6 │
│ Changelog: https://github.com/npm/cli/releases/tag/v6.14.6 │
│ Run npm install -g npm to update! │
│ │
╰────────────────────────────────────────────────────────────────╯
So then I go to upgrade npm:
$ npm install -g npm
Unhandled rejection Error: EACCES: permission denied, open '/Users/myuser/.npm/_cacache/tmp/54213b04'
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
...and I'm right back to where I started! What's going on here?!
Update
When I try to force a clean cache I also get errors:
$ npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.
npm ERR! path /Users/myuser/.npm/_cacache/content-v2
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rmdir
npm ERR! Error: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2'
npm ERR! [OperationalError: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2'] {
npm ERR! cause: [Error: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rmdir',
npm ERR! path: '/Users/myuser/.npm/_cacache/content-v2'
npm ERR! },
npm ERR! isOperational: true,
npm ERR! stack: "Error: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rmdir',
npm ERR! path: '/Users/myuser/.npm/_cacache/content-v2'
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 (though this is not recommended).
Update regarding potential permissions issue
Remember this is my own user's home directory, so I should absolutely have full access/privilege to use and have been using this laptop for years without any issues.
When I cd into /Users and run ls -al I get:
$ ls -al
total 0
drwxr-xr-x 5 root admin 160 Apr 9 2018 .
drwxr-xr-x 30 root wheel 960 May 2 2019 ..
-rw-r--r-- 1 root wheel 0 Jul 15 2017 .localized
drwxrwxrwt 5 root wheel 160 Apr 9 2018 Shared
drwxr-xr-x+ 117 myuser staff 3744 Jul 11 11:14 myuser
So again this could not possibly be an actual permission issue.
Update for trying to uninstall node and install nvm
I was able to follow this link to manually delete node/npm off my system. I then tried following this link to install nvm and it doesn't seem to work for me:
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 11329 100 11329 0 0 33913 0 --:--:-- --:--:-- --:--:-- 34123
=> Downloading nvm from git to '/Users/myuser/.nvm'
=> Cloning into '/Users/myuser/.nvm'...
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 7748 (delta 0), reused 1 (delta 0), pack-reused 7747
Receiving objects: 100% (7748/7748), 2.63 MiB | 1.77 MiB/s, done.
Resolving deltas: 100% (4905/4905), done.
* (HEAD detached at v0.33.0)
master
=> Compressing and cleaning up git repository
Counting objects: 7748, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (7684/7684), done.
Writing objects: 100% (7748/7748), done.
Total 7748 (delta 5188), reused 2329 (delta 0)
=> Appending nvm source string to /Users/myuser/.bashrc
=> bash_completion source string already in /Users/myuser/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="/Users/myuser/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
So I close my terminal and restart it and then run:
$ nvm --version
-bash: nvm: command not found

It looks you don't have permission to the directory:
cd /Users/myuser
chown -R $USER ./.npm
And please try again.
If it doesn't work, I recommend to remove your nodejs totally and install nvm and install nodejs using nvm.

Related

When I try to install nodemon i get this error message

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/nodemon
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir'/usr/local/lib/node_modules/nodemon'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/nodemon'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/nodemon'
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:
Looks like the problem is with the package generator-karma, not sure if this is the problem or not.
Can anyone show me what i need to do to get this installing correctly.
Thanks
Sanil
I believe you're trying to install a global package on your system by using npm install -g nodemon, then got permission denied, which is shown in error message.
You can't install a global package without root permission. If you want to do so, just execute it with root permission, like using sudo: sudo npm i -g nodemon or switch to root then execute again.
This looks like a permissions issue in your home directory. To reclaim ownership of the node_modules directory execute:
sudo chown -R $(whoami) ~/node_modules
Node.js error EACCES means you don't have access to the path it's specifying. In this case, /usr/local/lib/... is owned by the root user. See the command output here:
$ ls -l /usr/local/lib
total 12
drwxr-xr-x 4 root root 4096 Apr 7 23:45 node_modules
Nobody but root is allowed to write to the node_modules folder. This can be solved by prefixing your npm command with sudo to run the command as root.
See other: Understanding Linux File Permissions - Linuxize

npm ERR! code EACCESS by installing #angular/cli

Environment:
Ubuntu 16.04
node v8.11.1 (installed with package manager)
npm v5.6.0
After the clean installation of npm and trying to install #angular/cli
npm install -g #angular/cli
I'm getting an error related with EACCESS that it is probably related with permissions because it disappears with root access. The thing is that it is not recommended to use it that way, so how could I solve this?
Console ERROR
$ npm install -g #angular/cli
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! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2018-04-25T15_23_36_781Z-debug.log
File .npm/_logs/2018-04-25T15_23_36_781Z-debug.log
2566 warn checkPermissions Missing write access to /usr/lib/node_modules
2567 verbose stack Error: EACCES: permission denied, access '/usr/lib/node_modules'
2568 verbose cwd /opt/workspace/roscam-front
2569 verbose Linux 2.6.32-042stab120.19
2570 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "#angular/cli"
2571 verbose node v8.11.1
2572 verbose npm v5.6.0
2573 error path /usr/lib/node_modules
2574 error code EACCES
2575 error errno -13
2576 error syscall access
2577 error Error: EACCES: permission denied, access '/usr/lib/node_modules'
2577 error { Error: EACCES: permission denied, access '/usr/lib/node_modules'
2577 error stack: 'Error: EACCES: permission denied, access \'/usr/lib/node_modules\'',
2577 error errno: -13,
2577 error code: 'EACCES',
2577 error syscall: 'access',
2577 error path: '/usr/lib/node_modules' }
2578 error Please try running this command again as root/Administrator.
2579 verbose exit [ -13, true ]
One option to deal with this problem will be to change npm's default directory to use a different directory.
We need to make a directory for global installations, in this example inside user directory:
mkdir ~/.npm-global
We configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
Open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH
We update your system variables:
source ~/.profile
Now we can test by installing a package globally without using root permissions.
npm install -g jsonfile
Another option to avoid all these steps and modifying ~/.profile, it will be by defining an ENV variable with the following command(:
NPM_CONFIG_PREFIX=~/.npm-global
npm reference
I had the EACCES permission error too. I did a fresh install of Ubuntu 18.04. The 16.04 version may not be much different. It all works for me. Hope this helps.
----------- FOR YOU, YOU SHOULD APPLY THIS CODE FROM HERE
sudo apt-get install curl software-properties-common
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install nodejs
node -v
npm -v
npm init
whoami
which npm # returned /usr/bin
npm config get prefix # returned /usr
npm config set prefix /usr/bin
npm config get prefix
ls -la /usr/bin/npm # has a symbolic link to ../lib/node_modules/npm/bin/npm-cli.js
sudo chown -R your_user /usr/bin/npm # NOT /usr/bin or we lock out sudo too!!!!
sudo chown -R your_user app-folder/
ls -la /usr/bin/npm
npm init # I was curious to see if this still works
npm install # WORKS GREAT!!! No need for sudo now.:)
----------- TO THERE
THIS IS THE USE CASE I WORKED ON AFTER I INSTALLED THE ABOVE. YOURS SHALL WORK TOO IF THE ABOVE IS WELL SET UP.
npm start # script
npm run start:prod # works as well
npm i debug --save-dev # works but need to install 'make'
sudo apt install build-essential
npm i debug --save-dev # installed and launched successfully!
Note: if you were to install
npm i debug --global instead,
you may still get that EACCES permission error as your local user will not be able to access root permissions elsewhere in your file system. That's why we use 'change ownership' (i.e. chown your_user: see above in the code).

NPM cannot install module, permission denied with mkdir

I am attempting to globally install the electron module with npm on OS X Sierra. When I run
sudo npm install electron -g
I get
/usr/local/bin/electron -> /usr/local/lib/node_modules/electron/cli.js
> electron#1.7.5 postinstall /usr/local/lib/node_modules/electron
> node install.js
/usr/local/lib/node_modules/electron/install.js:48
throw err
^
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/electron/dist'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron#1.7.5 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron#1.7.5 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/ianwise/.npm/_logs/2017-08-10T22_16_42_927Z-debug.log
The problem seems to be a permission denied when npm runs mkdir... But I'm running this with sudo, so why is this a problem?
I think you're running as root. run the following command.
npm config set unsafe-perm true
sudo npm install electron -g
I had exactly the same issue with electron.
Assuming you have checked that the relevant directories are writable with:
$ ls -l
In the end I tried without sudo and it worked...!
$ npm install electron -g
The process completed with a message saying:
npm notice created a lockfile as package-lock.json. You should commit this file.
I just deleted the package-lock.json file
For me, the process also completed with a message saying:
npm update check failed
I followed the instructions at Ubuntu: npm update failed to fix this

Error: EACCES: permission denied when running `npm install` on Elastic Beanstalk

I've provisioned a default clean node.js app via Elastic Beanstalk, and have a node.js script trying to run npm install inside the project directory (/var/app/current/deploy-dist), however, the following permission error is thrown:
npm WARN locking Error: EACCES: permission denied, open '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock'
npm WARN locking at Error (native)
npm WARN locking /tmp/.npm/_locks/staging-f212e8d64a01707f.lock failed { Error: EACCES: permission denied, open '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock'
npm WARN locking at Error (native)
npm WARN locking errno: -13,
npm WARN locking code: 'EACCES',
npm WARN locking syscall: 'open',
npm WARN locking path: '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock' }
npm WARN deploy-dist No description
npm WARN deploy-dist No repository field.
npm WARN deploy-dist No license field.
npm ERR! Linux 4.4.35-33.55.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.9.1-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.9.1-linux-x64/bin/npm" "install"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! path /tmp/.npm/_locks/staging-f212e8d64a01707f.lock
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open
npm ERR! Error: EACCES: permission denied, open '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, open '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock'
npm ERR! at Error (native)
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'open',
npm ERR! path: '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock' }
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! /var/app/current/deploy-dist/npm-debug.log
The package.json is just a:
{
"dependencies": {
"node-fetch": "^1.3.3"
}
}
Running npm install with sudo obviously works, but is preferred to be avoided as a solution.
Setting NPM_CONFIG_PREFIX to a directory at ~ as per npm docs suggestion didn't work either, and the problem persists.
I suspect the problem lies in incorrect permissions for /tmp/.npm, which are
drwxr-xr-x 114 root root 4.0K Dec 27 17:04 .npm
This is confusing, as I expected a simple npm install to work out of the box.
UPDATE: Should not that the project directory already contains a node_modules folder, but even removing it and running npm install doesn't fix it.
I had this problem! You can use ebextensions to create a post-deploy script that changes the permissions of the tmp/npm/.locks folder.
In your node.js project, create a .ebextensions folder if you haven't got one already. Then, add a new config file, e.g. 00_create_postdeploy_script.config, with the following yaml:
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_fix_node_permissions.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
chown -R nodejs:nodejs /tmp/.npm/_locks/
When you deploy, this will create a script in /opt/elasticbeanstalk/hooks/appdeploy/post called 99_fix_node_permissions.sh, which looks like this:
#!/usr/bin/env bash
chown -R nodejs:nodejs /tmp/.npm/_locks/
Because it's in that post folder, it will be run automatically after your app has deployed -- and hence change the permissions as required.
EDIT: If you're having trouble with the permissions of the whole .npm folder, then you should change the last line of the config file to:
chown -R nodejs:nodejs /tmp/.npm/
I have had this problem in past and in my case cleaning the cache fixed my issue.
Please try this
npm cache clean
Hope it helps.
The following command will fix the issue. it worked for me.
sudo chown -R 1000:1000 "/home/user/.npm"

Node.js : NPM Install Fails

I get this error if I run
curl http://npmjs.org/install.sh | sh
even with sudo.
cirk#cirk-Parallels-Virtual-Platform:~$ curl http://npmjs.org/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3902 100 3902 0 0 6138 0 --:--:-- --:--:-- --:--:-- 12546
fetching: http://registry.npmjs.org/npm/-/npm-1.0.18.tgz
0.4.9
1.0.18
Skipping 0.x cruft clean
! [ -d .git ] || git submodule update --init --recursive
node cli.js cache clean
node cli.js rm npm -g -f --loglevel error
node cli.js install -g -f
npm ERR! error installing npm#1.0.18 Error: EACCES, Permission denied '../lib/node_modules/npm/bin/npm.js'
npm ERR! Error: EACCES, Permission denied '../lib/node_modules/npm/bin/npm.js'
npm ERR!
npm ERR! Please use 'sudo' or log in as root to run this command.
npm ERR!
npm ERR! sudo npm "install" "-g" "-f"
npm ERR!
npm ERR! or set the 'unsafe-perm' config var to true.
npm ERR!
npm ERR! npm config set unsafe-perm true
npm ERR!
npm ERR! System Linux 2.6.38-10-generic
npm ERR! command "node" "/tmp/npm.1568/package/cli.js" "install" "-g" "-f"
npm ERR! cwd /tmp/npm.1568/package
npm ERR! node -v v0.4.9
npm ERR! npm -v 1.0.18
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/npm.1568/package/npm-debug.log
npm not ok
It worked
What should I do? I tried these with no success:
chown -R cirk /usr/lib/nodejs
// and also this
chown -R cirk /usr/lib/node_modules (node_modules is empty it tries to install NPM here or what)
actually it did something, as you can see it writes at the end It worked what is a big lie!
Why are you running that in /usr?
If you really need to, this page suggests you may run that as root, so that would be:
curl https://www.npmjs.com/install.sh | sudo sh
But you better make sure it won't break your system, before running that.
I screwed up the permissions on my npm installation, and had this error when reinstalling. I solved it in the crudest way: by liberally sudo rm -rfing any directory tree that gave me trouble, then recompiling node.js and reinstalling npm.
If all else fails, you could fall back to that.

Resources