Installation Node v4.1 with NVM - Permission denied - node.js

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%

Related

Node install issues on MacOS 10.14.6

I'm very new to Homebrew and Node and am having troubles getting Node up and running.
I successfully installed Homebrew, I then run brew install node and get:
Updating Homebrew...
Warning: node 13.2.0 is already installed, it's just not linked
You can use `brew link node` to link this version.
I run brew link node and get:
Linking /usr/local/Cellar/node/13.2.0...
Error: Could not symlink include/node/common.gypi
/usr/local/include/node is not writable.
Does anyone know how to fix this? Guessing it has something to do with my file not being "writable" but not sure. Thank you so much!
It seems you have a permission problem. The directories that homebrew tries to install node into have to be writable. Try this; it sets your user as owner of these subdirectories:
chown -R `whoami`:admin /usr/local/bin
chown -R `whoami`:admin /usr/local/share
chown -R `whoami`:admin /usr/local/include
and then try installing node again. You might have to brew uninstall node before brew install node.
Grab from the previous post:
$ sudo chown -R $(whoami) $(brew --prefix)/* is the solution.

Installation nvm in Ubuntu 14.04

I have to install nvm on Ubuntu 14.04 for a work and this is the guide that I have to follow:
Installation of nvm globally
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
Installation of node v 4.x
sudo mkdir /usr/local/node
sudo chown -R root:dev /usr/local/node
sudo chmod -R 775 /usr/local/node
nvm stable
The problems are that in the passage 6 I don't know exactly what to do or write in the file nvm.sh and then the last command tells me "nvm: command not found"
you should add to nvm.sh the following content:
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"
refer also to this answer

Accessing nodejs as non root

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?

can't brew install node

I am trying to upgrade my node via homebrew but ran into a problem because I think I tried to download through the website. I am very new to terminal. I've tried to search for answers but many people say you can just delete the unbrewed header files. I am not sure how to do that. but for some reason when I try to brew install node, it says the brew link step did not complete successfully.
I also tried to brew link node but that doesn't work either. I ran out of options so I came here.
[SICNARF#WOPR ~]$ brew install node
==> Downloading https://homebrew.bintray.com/bottles/node-0.12.7.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/node-0.12.7.yosemite.bottle.tar.gz
==> Pouring node-0.12.7.yosemite.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink include/node/android-ifaddrs.h
/usr/local/include/node is not writable.
You can try again using:
brew link node
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall node`
==> Summary
🍺 /usr/local/Cellar/node/0.12.7: 2726 files, 31M
this is what happens when i brew doctor
[SICNARF#WOPR ~]$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
/usr/local/include/node/ares.h
/usr/local/include/node/ares_version.h
/usr/local/include/node/libplatform/libplatform.h
/usr/local/include/node/nameser.h
/usr/local/include/node/node.h
/usr/local/include/node/node_buffer.h
/usr/local/include/node/node_internals.h
/usr/local/include/node/node_object_wrap.h
/usr/local/include/node/node_version.h
/usr/local/include/node/openssl/aes.h
/usr/local/include/node/openssl/asn1.h
/usr/local/include/node/openssl/asn1_mac.h
/usr/local/include/node/openssl/asn1t.h
/usr/local/include/node/openssl/bio.h
/usr/local/include/node/openssl/blowfish.h
/usr/local/include/node/openssl/bn.h
/usr/local/include/node/openssl/buffer.h
/usr/local/include/node/openssl/camellia.h
/usr/local/include/node/openssl/cast.h
/usr/local/include/node/openssl/cmac.h
/usr/local/include/node/openssl/cms.h
/usr/local/include/node/openssl/comp.h
/usr/local/include/node/openssl/conf.h
/usr/local/include/node/openssl/conf_api.h
/usr/local/include/node/openssl/crypto.h
/usr/local/include/node/openssl/des.h
/usr/local/include/node/openssl/des_old.h
/usr/local/include/node/openssl/dh.h
/usr/local/include/node/openssl/dsa.h
/usr/local/include/node/openssl/dso.h
/usr/local/include/node/openssl/dtls1.h
/usr/local/include/node/openssl/e_os2.h
/usr/local/include/node/openssl/ebcdic.h
/usr/local/include/node/openssl/ec.h
/usr/local/include/node/openssl/ecdh.h
/usr/local/include/node/openssl/ecdsa.h
/usr/local/include/node/openssl/engine.h
/usr/local/include/node/openssl/err.h
/usr/local/include/node/openssl/evp.h
/usr/local/include/node/openssl/hmac.h
/usr/local/include/node/openssl/idea.h
/usr/local/include/node/openssl/krb5_asn.h
/usr/local/include/node/openssl/kssl.h
/usr/local/include/node/openssl/lhash.h
/usr/local/include/node/openssl/md4.h
/usr/local/include/node/openssl/md5.h
/usr/local/include/node/openssl/mdc2.h
/usr/local/include/node/openssl/modes.h
/usr/local/include/node/openssl/obj_mac.h
/usr/local/include/node/openssl/objects.h
/usr/local/include/node/openssl/ocsp.h
/usr/local/include/node/openssl/opensslconf.h
/usr/local/include/node/openssl/opensslv.h
/usr/local/include/node/openssl/ossl_typ.h
/usr/local/include/node/openssl/pem.h
/usr/local/include/node/openssl/pem2.h
/usr/local/include/node/openssl/pkcs12.h
/usr/local/include/node/openssl/pkcs7.h
/usr/local/include/node/openssl/pqueue.h
/usr/local/include/node/openssl/rand.h
/usr/local/include/node/openssl/rc2.h
/usr/local/include/node/openssl/rc4.h
/usr/local/include/node/openssl/ripemd.h
/usr/local/include/node/openssl/rsa.h
/usr/local/include/node/openssl/safestack.h
/usr/local/include/node/openssl/seed.h
/usr/local/include/node/openssl/sha.h
/usr/local/include/node/openssl/srp.h
/usr/local/include/node/openssl/srtp.h
/usr/local/include/node/openssl/ssl.h
/usr/local/include/node/openssl/ssl2.h
/usr/local/include/node/openssl/ssl23.h
/usr/local/include/node/openssl/ssl3.h
/usr/local/include/node/openssl/stack.h
/usr/local/include/node/openssl/symhacks.h
/usr/local/include/node/openssl/tls1.h
/usr/local/include/node/openssl/ts.h
/usr/local/include/node/openssl/txt_db.h
/usr/local/include/node/openssl/ui.h
/usr/local/include/node/openssl/ui_compat.h
/usr/local/include/node/openssl/whrlpool.h
/usr/local/include/node/openssl/x509.h
/usr/local/include/node/openssl/x509_vfy.h
/usr/local/include/node/openssl/x509v3.h
/usr/local/include/node/pthread-fixes.h
/usr/local/include/node/smalloc.h
/usr/local/include/node/stdint-msvc2008.h
/usr/local/include/node/tree.h
/usr/local/include/node/uv-aix.h
/usr/local/include/node/uv-bsd.h
/usr/local/include/node/uv-darwin.h
/usr/local/include/node/uv-errno.h
/usr/local/include/node/uv-linux.h
/usr/local/include/node/uv-sunos.h
/usr/local/include/node/uv-threadpool.h
/usr/local/include/node/uv-unix.h
/usr/local/include/node/uv-version.h
/usr/local/include/node/uv-win.h
/usr/local/include/node/uv.h
/usr/local/include/node/v8-debug.h
/usr/local/include/node/v8-platform.h
/usr/local/include/node/v8-profiler.h
/usr/local/include/node/v8-testing.h
/usr/local/include/node/v8-util.h
/usr/local/include/node/v8.h
/usr/local/include/node/v8config.h
/usr/local/include/node/v8stdint.h
/usr/local/include/node/zconf.h
/usr/local/include/node/zlib.h
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
node
[SICNARF#WOPR ~]$ brew link
This command requires a keg argument
[SICNARF#WOPR ~]$ brew link node
Linking /usr/local/Cellar/node/0.12.7...
Error: Could not symlink include/node/android-ifaddrs.h
/usr/local/include/node is not writable.
There are two steps involved.
Simply run these four commands:
sudo chown -R `whoami`:admin /usr/local/include/node
sudo chown -R `whoami`:admin /usr/local/bin
sudo chown -R `whoami`:admin /usr/local/share
sudo chown -R `whoami`:admin /usr/local/lib/dtrace
Finally, run the overwrite command:
brew link --overwrite node
I ran into this same issue under the same circumstances. I was able to get the brew version to install successfully by:
Run brew install node
Make note of the module that is causing the issue and delete it. In your case, this would be /usr/local/include/node
Uninstall - brew uninstall node
Re-install - brew install node
I had to repeat this process a few times for each remaining problematic directory (about 3 different ones in actuality), and the install eventually succeeded without any issues.
I ran into this problem on a new MacBook Pro on Mac OS High Sierra. I gleaned brew was trying to use directories named include and lib under /usr/local that was not there. Since root owns /usr I had to do it manually - making sure that whoami owner matches peer directories in /usr/local:
sudo mkdir /usr/local/include
chown `whoami`:admin /usr/local/include
sudo mkdir /usr/local/lib
chown `whoami`:admin /usr/local/lib
And then to match the other directories in /usr/local I did:
chmod 775 /usr/local/include
chmod 775 /usr/local/lib
then the following worked:
brew uninstall node
brew install node
You need to make /usr/local/bin and /usr/local/share writable. I used this answer to achieve this. Below is the key advice in the answer replicated in case the link breaks:
sudo chown -R `whoami`:admin /usr/local/bin
sudo chown -R `whoami`:admin /usr/local/share
I had the same error:
Linking /usr/local/Cellar/node/11.10.0...
Error: Could not symlink include/node /usr/local/include is not writable.
Solution:
$ sudo mkdir /usr/local/include
$ sudo chown -R $(whoami) $(brew --prefix)/*
$ brew link node
Linking /usr/local/Cellar/node/11.10.0... 7 symlinks created
$ node -v => v11.10.0
$ npm -v => 6.7.0
brew postinstall node or brew link --overwrite node doesn't seem to help.
After several rounds of brew uninstall node and brew install node the following were the offending directories and files:
sudo rm -r /usr/local/include/node
sudo rm -r /usr/local/share/doc/node
sudo rm -r /usr/local/lib/node_modules
sudo rm /usr/local/lib/dtrace/node.d
sudo rm /usr/local/share/man/man1/node.1
sudo rm /usr/local/share/systemtap/tapset/node.stp
After the offending files are removed brew will do all the proper linking with permissions for you.
Likely permissions were set as root:wheel because of a past install with sudo or perhaps manual installation, etc.
For those running high sierra on MacOS:
I tried giving permissions using the chown command and uninstalling then reinstalling node via homebrew but nothing worked.
I just went to this site https://nodejs.org/en/download/ and downloaded the 64 bit macOS .pkg and it worked perfectly. I tested it by just entering the command node in terminal.
I had a very similar problem with linking. I couldn't get it to work. I tried to chmod /usr/local/include/node so I could write the link to it but ran into another error. As a final solution, I just reinstalled node from https://nodejs.org/download/
I have a working node prompt again! I would love to go through brew to update but it saved me a lot of hassle just using the pkg installer from the site. I know this may not be the solution you are looking for but I just wanted to share my experience with the same issue. I hope it helps!
brew link --overwrite node
Error: Could not symlink (...)
/usr/xxx
sudo chown -R 'whoami?':admin xxx
brew link --overwrite node
Rinse and repeat
For me I had to run brew doctor which showed me that I did not have write access and had to run sudo chown -R $(whoami) /usr/local/bin /usr/local/share /usr/local/share/man to fix the issue.
I suggest running brew doctor to see if it can provide some hints on the issue
remove the error folder or file manually and run this command brew uninstall node && brew install node
You have to do this process till all error folder and files are removed.
Then node will be linked.
If you try to brew link node and it says something along the lines:
Error: Could not symlink include/node/openssl/archs/aix-gcc/asm/include/openssl/opensslconf.h
Target /usr/local/include/node/openssl/archs/aix-gcc/asm/include/openssl/opensslconf.h
already exists. You may want to remove it:
Try this:
brew link --overwrite --dry-run node | xargs rm
brew link node

Trouble install node.js with homebrew

I'm trying to install Node.js with Homebrew (I installed it previously without using brew, and I've tried deleting all of those files). I've looked at previous questions asking similar things, but I haven't been able to get them to work. First I tried brew link node which gave me:
myusername#c126h060:~$ brew link node
Linking /usr/local/Cellar/node/0.12.6...
Error: Could not symlink share/systemtap/tapset/node.stp
Target /usr/local/share/systemtap/tapset/node.stp
already exists. You may want to remove it:
rm '/usr/local/share/systemtap/tapset/node.stp'
To force the link and overwrite all conflicting files:
brew link --overwrite node
To list all files that would be deleted:
brew link --overwrite --dry-run node
And then when I run brew link --overwrite node I get the following:
myusername#c126h060:~$ brew link --overwrite node
Linking /usr/local/Cellar/node/0.12.6...
Error: Could not symlink share/systemtap/tapset/node.stp
/usr/local/share/systemtap/tapset is not writable.
Additionally, when I tried using brew link -n node to find files to manually delete, I managed to delete some of them, but I'm still left with the following files that I can't delete:
myusername#c126h060:~$ brew link -n node
Would link:
/usr/local/etc/bash_completion.d/npm
/usr/local/bin/node
/usr/local/include/node
/usr/local/share/man/man1/node.1
/usr/local/share/systemtap/tapset/node.stp
/usr/local/lib/dtrace/node.d
When I try to delete I get the following (same thing for all of these files):
myusername#c126h060:~$ rm /usr/local/etc/bash_completion.d/npm
rm: /usr/local/etc/bash_completion.d/npm: No such file or directory
What should I do?
It may be that you don't actually own your systemtap directory. Navigate to /usr/local/share and run this command in order to make yourself the owner:
chown -R <yourusername>:<yourgroupname> systemtap
When I was fixing this same issue earlier today, I had to also go into /usr/local and do the same thing for the lib directory.
get your username,
and get your groups:(could be more than one,generally is 'admin')
whoami
groups
then, for exapmle:
sudo chown -R chrislee:admin /usr/local/share/systemtap/
Or, alternatively, verify the ownership and permissions on systemtap
$ ls -al /usr/local/share/systemtap/
drwxr-xr-x 3 root wheel 102 Oct 23 18:06 .
drwxrwxr-x 15 root wheel 510 Oct 24 20:24 ..
drwxr-xr-x 2 root wheel 68 Oct 24 20:17 tapset
then add yourself to the owner group (in this case wheel)
sudo dscl . append /Groups/wheel GroupMembership <username>
then change the permissions on tapset to allow group edits
sudo chmod -R 775 /usr/local/share/systemtap/tapset/
What worked for me:
cd /usr/local/share
sudo chown -R <user>:<group> systemtap (Did 1 & 2 for /usr/local too)
Above steps were failing. Went to next answer. Tried;
ls -al /usr/local/share/systemtap/
which throwed a 'Not found error.'
Then: brew link node was throwing an error. So I did:
sudo rm -rf /usr/local/lib/node_modules
brew postinstall node -v
And at last brew link node
node -v :)
So basically I removed all node_modules/ folders and redid everything.
arun:~$ brew link node
Linking /usr/local/Cellar/node/0.12.6...
Error: Could not symlink share/systemtap/tapset/node.stp
Target /usr/local/share/systemtap/tapset/node.stp
already exists. You may want to remove it:
rm '/usr/local/share/systemtap/tapset/node.stp'
Run below commands
brew postinstall node -v
brew link node
The following recipe worked for me:
Add your username to add group wheel sudo dscl . append /Groups/wheel GroupMembership username
sudo chmod -R 775 /usr/local/share/systemtap/tapset/
sudo rm -rf /usr/local/lib/node_modules
brew cleanup
brew link node
brew uninstall --force node
brew install node
Then check version with node -v and npm -v.
This command was the answer for the error message for me. It changes the folder permissions to the current user:
sudo chown -R $(whoami) /usr/local/share/systemtap
just add sudo in the beginning of the command npm install expo-cli --global
like sudo npm install expo-cli --global and hit enter.
hope it'll help you.

Resources