Are you using any Debian based linux machine ?
- If you say Yes, you might face the permission issue with NPM.
Issue is every time I run npm command it's getting EACCESS error.
It means I have to run the command as a super user mode, but I don't like that.
I have been facing this issue from couple of days.
Finally, I decided to fix this issue.
Let's see how did I fix the issue.
There are couple of ways to fix this issue:
I think first one is simple.
As far as I know this command should work.
I followed the second option which is changing the npm default directory.
The reason I choose the second option is :
There are times when you do not want to change ownership of the default directory that npm uses (i.e. /usr) as this could cause some problems, for example if you are sharing the system with other users.
Instead, you can configure npm to use a different directory altogether. In our case, this will be a hidden directory in our home folder.
Step-1 Make a directory for global installations:
Step-2 Configure npm to use the new directory path:
Step-3 Open or create a .profile file and add this line:
Step-4 Back on the command line, update your system variables:
Instead of steps 2-4 you can also use the corresponding ENV variable (e.g. if you don't want to modify .profile):
I don't want to change the profile file so I used above command.
Now my problem is fixed :-).
- If you say Yes, you might face the permission issue with NPM.
Issue is every time I run npm command it's getting EACCESS error.
It means I have to run the command as a super user mode, but I don't like that.
sudo npm install [module name]
I have been facing this issue from couple of days.
Finally, I decided to fix this issue.
Let's see how did I fix the issue.
There are couple of ways to fix this issue:
- Change the permission to npm's default directory.
- Change npm's default directory to another directory.
- Install node with a package manager that takes care of this for you.
I think first one is simple.
As far as I know this command should work.
sudo chown -R kernellora /usr/local/lib/node_modules/
I followed the second option which is changing the npm default directory.
The reason I choose the second option is :
There are times when you do not want to change ownership of the default directory that npm uses (i.e. /usr) as this could cause some problems, for example if you are sharing the system with other users.
Instead, you can configure npm to use a different directory altogether. In our case, this will be a hidden directory in our home folder.
Step-1 Make a directory for global installations:
mkdir .npm-global
Step-2 Configure npm to use the new directory path:
npm config set prefix '.npm-global'
Step-3 Open or create a .profile file and add this line:
export PATH=/.npm-global/bin:$PATH
Step-4 Back on the command line, update your system variables:
source .profile
Instead of steps 2-4 you can also use the corresponding ENV variable (e.g. if you don't want to modify .profile):
NPM_CONFIG_PREFIX=.npm-global
I don't want to change the profile file so I used above command.
Now my problem is fixed :-).
No comments:
Post a Comment