Npm getting permission errors - node.js

when I try to globally install any modules, I receive the following error...
[Bot (9)] npm install -g miscord
/home/myhome/nodevenv/Bot/9/bin/npm: line 14: /bin/ln: Permission denied
I can install locally, and from what I understood there is no ln folder or script, additionally, it's not writing the miscord folder or files. I am running Nodejs in an environment where I do not have root permissions however it is setup via CPanel, Nodenv and with ssh access. I have tried a few different modules all giving me the same error.

Try to set your specific permissions for npm sudo npm -g config set user YourUser https://docs.npmjs.com/cli/config.html

Related

Create vue Permission denied

I'm trying to install vue app using this command "npm init vue#latest",
But the following error occurred with me, any help :(
Note : I tried many solutions like : chmod -R 755 .npm and sudo chown -R mostafa .npm but nothing changes
maybe you could try using the vue-cli like this:
npm install -g #vue/cli && vue create hello-world
If this wouldn't work then I'd suggest to reinstall node/npm
You should probably also make a clean installation of these tools so that you don't need to run such things as administrator
In order to install vue on your machine you must first have installed nodejs ( package manager node package manager ) to which the acronym npm refers, I leave you the linux commands under :
install :
sudo apt install nodejs
shows the installed version of nodejs :
node -v
After installing nodejs try relaunching the command to install vue
if you have already installed them try with this :
add write permissions to the study folder , and not to the mostafa folder , linux only assigns permissions to the folder in the chmod command and not subfolders, try these commands :
cd home/mostafa/Dowloads
sudo chmod ugo+w study
Are you not being blocked by SELinux directives?
Try running the same command using your least privileged user (normal user).
And please avoid using the root user for everyday tasks.
You need to have installed Nodejs, vue and create-vue.
sudo apt install nodejs
npm install vue#latest
npm install create-vue#latest
Now you can run the command to start the new project with Vue.
npm init vue#latest

Error: EACCES: permission denied NPM Ubuntu Server

I am running an Ubuntu EC2 server and followed the tutorial provided by AWS to install nvm and node, but when I try to run npm install, I'm thrown an error:
Error: EACCES: permission denied, access '/var/www/app'
Please try running this command again as root/Administrator.
The standard procedure with an EC2 Ubuntu service appears to only provide a ubuntu user with sudo privileges and no access to root so I tried to run sudo npm install, but I receive sudo: npm: command not found. The reason why I believe this is happening is because nvm is located at /home/ubuntu/.nvm/versions/node/v6.12.3/bin/node, which root might not have access to?
Is it possible to point root to the this directory location for this command or is there a different solution?
You're getting that error because you do not have write permission for your user on that /var/www/app.
You can follow the answer here to give permissions to that folder.
https://askubuntu.com/questions/749697/how-do-i-give-myself-access-to-var-www-to-create-and-edit-files-and-folders-in
You are getting the error about npm not being installed when you use sudo because it is not installed for the admin user. I would avoid installing node and npm through sudo though. Just go with changing the folder permissions.

"npm install express-react-views" result in access error

I want to install express-react-views in Ubuntu 14.04 locally(not globally) but the installation results in an access error--it is trying to access global npm folder.
Anything I have done wrongly or express-react-views requires sudo privilege?

Fix for npm global install on Ubuntu

I have a nodejs package that requires a global install. This one fails in a way that leads me to believe there might be a configuration problem in the the Ubuntu package npm. This happens every-time I setup an Ubuntu 14.04 machine.
sudo apt-get install npm
npm install -g lineman
The npm -g command will throw some access error naming the local lib and bin directories. Unlike some global installs, it is not an option to cheat and run the second command under sudo. So, the only fix I have found that will work is something like this:
sudo chgrp -R $(whoami) /usr/local/bin /usr/local/lib
sudo chmod -R g+rwx /usr/local/bin /usr/local/lib
The fix is fine for me, I'm the only user. But is this really the best way to do it? I don't want to document my fix for anyone else that might use it in an environment where this will not work or cause trouble.
Also, should I file a bug report with someone who packages npm for Ubuntu?
Instead of npm install -g lineman, you should run sudo npm install -g lineman. npm requires permission as well.
Also check this stackoverlfow link.

nodejs - failing to install contextify via npm

Getting errors regarding "node-gyp rebuild" but can't seem to figure out why?
Full error: http://pastebin.com/HJ4z6tie
Perhaps, this links and solutions will be useful for you:
1) https://github.com/hideo55/node-murmurhash3/issues/4
Problem:
When I run the command sudo npm link your NPM is failing.
Solution:
when I use --unsafe-perm=true this NPM works.
2) https://github.com/npm/npm/wiki/Troubleshooting#permission-error
Permission Error
npm ERR! code EPERM
npm ERR! code EACCES
Fix the permissions of your cache with sudo chown -R $(whoami) "$HOME/.npm".
Try again with sudo. e.g. sudo npm install express -g. (You'll probably need to fix cache permissions afterwards, as above).
Reinstall node so it doesn't require sudo.
The EACCES error code means that the process does not have permissions to read/write in the target directory/file. As is common with package managers, this usualy means the module could not be installed to target directory.
This may be fixed by running the command as super user (sudo ...), but preferrably you would just fix the file permissions so that the account that runs the command has necessary permissions to the target directory.
As a side-note, the EACCES error comes from the great Linux itself - see the list of other error codes (or run man errno) one might encounter.
Define environment variable NODE_PATH as such :
export NODE_PARENT=${HOME}/node-v0.12.0
export PATH=${NODE_PARENT}/bin:${PATH} # so executables are found
export NODE_PATH=${NODE_PARENT}/lib/node_modules # so node can find modules
./configure --prefix=${NODE_PARENT}
do this when installing Node from source ... which gives you node and npm
and will avoid all such permission errors ... then install modules as yourself ... no need for root
npm install -g some-global-module

Resources