I'm trying to install Vue CLI on ubuntu 20.04 with the following command:
sudo npm install -g #vue/cli
I got permission denied error
2021/06/13 14:35:24.163955 cmd_run.go:1002: WARNING: cannot create user data directory: cannot create "/nonexistent/snap/node/4749": mkdir /nonexistent: permission denied
I used the following code to solve the permission denied problem in the directory that I'm developing the project but the solution did not solve the problem
chmod -R 777 /Desktop/vuejs
I founded the solution because I installed node js using Snap package from Snap Store, which has different permission caused the problem. installing Vue CLI using npm needed permission for making a directory in the snap directory, even changing permissions to 777 in the snap directory is not a good solution becouse changing file system directories permission like snap or usr hurts your ubuntu operation system, in my case after changing usr and snap directory permission to 777 my root permission gone and I had to reinstall ubuntu operation system
you can install node js version 14.x using apt with the following command
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
also the following link is useful to install other nodejs versions
nodejs debinstall
Related
I am trying to update node from 10 to 12 on my mac 11.6 (20G165).
And I would like to use the homebrew way:
brew upgrade node
However, after running this, I got:
$ brew upgrade node
Error: The following directories are not writable by your user:
/usr/local/share/man/man5
/usr/local/share/man/man7
Well, then I tried the sudo way:
sudo brew upgrade node
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
What should I do to fix it now?
Can I just grant the
/usr/local/share/man/man5
/usr/local/share/man/man7
directories to my current user? Is there any risk by doing so?
My homebrew version:
Homebrew 3.2.17
Homebrew/homebrew-core (git revision 0e79905a9e5; last commit 2021-10-20)
Well I had a same problem, and solved it by commands provided which were followed by error.
sudo chown -R $(whoami) /usr/local/share/man/man5 /usr/local/share/man/man7
And make sure that your user has write permission.
chmod u+w /usr/local/share/man/man5 /usr/local/share/man/man7
First of all, I run node in macOS terminal, and get
bash: /usr/local/bin/node: No such file or directory
I run brew install node and get
Warning: node 12.10.0 is already installed, it's just not linked You can use `brew link node` to link this version.
So I run brew link node and get
Error: Could not symlink include/node/common.gypi
/usr/local/include/node is not writable.
I suppose that's some permission issue. So I run it with sudo and get
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
Then I try brew uninstall node, and repeat all the above steps, and still get the same errors. What do I do?
Note: Never use sudo with brew. Running brew as root may change the owner of brew related files, and make it inaccessible by current user.
Answer for the question: you may have broken the permission of /usr/local/include/node directory already by using sudo. To fix this,
rm -rf /usr/local/include/node
brew unlink node
brew link node
If the above commands don't fix your problem. Try to fix all folder permission under /usr/local recursively. Then try the above fix again.
sudo chown -R $(whoami):admin /usr/local/*
I figured it out. Doing brew link --overwrite node worked.
I'm trying to install globally some packages for my Unix environment on Windows with WSL. I use nvm to manage the different versions of Node.js.
The problem is while using the sudo command before a global npm install :
sudo npm install --global prompt-pure
I get an error: sudo: npm: command not found !
Doing a simple npm install --global pure-prompt will work, but as I'm not super user, the global installation ends up with a permission error.
How can I fix this annoying problem and keep nvm ?
Thanks by advance
When you try to run sudo npm, it tries to run the npm binary file /usr/bin/npm but your binary is located in a different place, which can be found running which npm.
Example: /home/damo/.nvm/versions/node/v8.11.1/bin/npm
The solution is to create a link in /usr/bin/ pointing to the actual binary:
sudo ln -s "$(which npm)" /usr/bin/npm
You can also add the following link so you can run sudo node
sudo ln -s "$(which node)" /usr/bin/node
For me I needed to actually cheat and run as root before installing node as root. For this I ran sudo su in a Ubuntu WSL term and then installed node.
Once I did that I could sudo su then npm run special-script.
I don't know a better way to get a script to attach to restricted ports like 443 for testing https connections but it works.
As you will find in the man file for sudo man sudo sudo will execute a command as another user. That other user has a different home directory to you and access to different commands
When i run sudo which node i get nothing, but which node returns /home/damo/.nvm/versions/node/v8.11.1/bin/node
Lets look at your actual goal. You say you are trying to install pure-prompt, i know this does not ask your explicit question but given you have zsh installed have you tried oh-my-zsh (https://github.com/robbyrussell/oh-my-zsh) i use this on every install of linux i ever have to work with (VMs, WSL, docker). Very customizable and looks great out of the box.
I have to install Node v4.1.x on Ubuntu. I have already installed it but with the wrong version. This are the steps that I followed untill now:
Installation of nvm
sudo git clone https://github.com/creationix/nvm.git /opt/nvm
sudo mkdir /usr/local/nvm
sudo addgroup -system dev
sudo chown -R root:dev /usr/local/nvm
sudo chmod -R 775 /usr/local/nvm
sudo vim /etc/profile.d/nvm.sh
Editing of the file
export NVM_DIR=/usr/local/nvm
source /opt/nvm/nvm.sh
export NPM_CONFIG_PREFIX=/usr/local/node
export PATH="/usr/local/node/bin:$PATH"
Installation of Node
sudo mkdir /usr/local/node
sudo chown -R root:dev /usr/local/node
sudo chmod -R 775 /usr/local/node
nvm stable
For installing node v4.1.x this is what I want to do:
nvm ls //list of all version
nvm use 4.1.x //if I find the correct version in the list
The problem is that I can't make nvm ls because I get
mkdir: cannot create directory ‘/usr/local/nvm/alias’: Permission denied
What can I do?
I think you might change NVM_DIR to:
NVM_DIR="$HOME/.nvm"
The problem is that you've installed nvm using root user (with sudo). When executing nvm commands later:
nvm ls
nvm use 4.1.x
you do this without root and you get a permission denied.
Generally it is not recommended to install nvm using super user.
Please check this article for more details on how to install the version manager: http://rainsoft.io/install-node-like-a-boss-with-nvm/
This can also be because of issues during the curl installation.
Try reinstalling using
sudo apt-get install build-essential libssl-dev curl git-core
In your case issue because you gave 755 permission to the nvm folder. So it cant create folder without write permission as non root user.
Solution is you should be a root user or else give write permission for the folder to your particular user.
I too faced the same issue while installing nvm
ubuntu#ip-10-0-0-94:~$ nvm install 6.0.0
It reported as,
nvm install 6.0.0 mkdir: cannot create directory ‘/home/ubuntu/.nvm/bin’: Permission denied
grep: /home/ubuntu/.nvm/bin/node-v6.0.0-linux-x64/node-v6.0.0-linux-x64.tar.xz: No such file or directory Binary download failed
It with the 755 permission before.
drwxr-xr-x 4 root root 4096 Jun 23 07:44 .nvm/
Then I just gave write permission for it.
sudo chmod +w .nvm
Now issue was resolved and working fine.
ubuntu#ip-10-0-0-94:~$ nvm install 6.0.0
Downloading https://nodejs.org/dist/v6.0.0/node-v6.0.0-linux-x64.tar.xz...
######################################################################## 100.0%
I have node 0.10.x installed via apt-get and also nvm/npm.
I used nvm to install node 0.12.7 and used this command
(n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local)
to copy the node binaries to /usr/local/ so that other users can use the version I chose using nvm. However getting the following error trying to do an npm install:
bash: /usr/local/bin/npm: /root/.nvm/versions/v0.12.7/bin/node: bad
interpreter: Permission denied
Any advice?