npm install throws error after a fresh install of node modules - node.js

After upgrading my node to v 4.2 , executed npm install for my node project as a root user from my home directory and it is successful. But started throwing module not found or can not find js file errors including binding exception while starting my app.

You solved your problem.
Because installing application without superuser permission prevent the other dependencies to be installed.
I recommend to enter to super user / root by sudo su - when installing.

Run 'sudo npm install' to avoid exceptions and it creates node_modules directory with current user. This solved my problem.

Related

`npm run` giving permission denied

I've started facing an issue today which was not occurring before and no code has been changed on my end.
I'm using Laravel 8 with Laravel Mix and when I run npm run prod I keep getting the following:
> prod
> npm run production
> production
> mix --production
/tmp/production65665869399.sh: 2: mix: Permission denied
Do you have any idea?
I even tried making /tmp directory to have 777 permission and tried to change the owner to be the user I'm logged in as but still the same issue.
It's started all of a sudden and there is no resource about it in the internet.
I'm using Node version 14.15.0 and npm version 8.13.2
This error doesn't occur on my local environment but on AWS Ubuntu server.
Tried to uninstall your node js, and just reinstall it using NVM. Make sure you are not running as root user while installing, hopefully this link can help you:
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04

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

Not able to install #angular/cli

I am getting errors while installing anuglar cli. I am working on the system which I don't have admin rights to. So, I followed below link to install node & npm & correct node & npm version is displayed in command prompt.
Install NodeJS & NPM without admin access
This is the error I am getting while installing angular cli. I have tried many options from previous SO answers but nothing worked. I have given explicit full control to the myself on C:\NodeJS\NodeJS folder. What are the options now?
One workaround would be to switch to a directory you have rights to and run the installation command without the -g flag.
C:\Users\user>cd C:\npm-global
C:\npm-global>npm cache clean --force
C:\npm-global>npm install #angular/cli
And add the bin folder of node_modules to the user environment variable PATH.

Ionic, npm and cordova commands all require sudo to work

The sudo, by the looks of what I have seen in some forums, is why I am getting an error when running sudo ionic emulate ios in this post New to ionic - can’t build for ios (9) on El Capitan, and sudo ionic is required, deprecated npmconf. (I am running El Capitan btw).
Whenever I need to use an ionic, npm, or cordova command, I always have to put sudo in front of it otherwise I get a "bash command not found" error. I have tried to use this fix https://www.npmjs.com/package/npm-sudo-fix but it doesn't work. This is what happens in the log:
Dylans-MBP:Ionic Projects Dylan $ sudo npm install -g npm-sudo-fix
Password:
/usr/local/bin/npm-sudo-fix -> /usr/local/lib/node_modules/npm-sudo-fix/index.js
npm-sudo-fix#0.1.3 /usr/local/lib/node_modules/npm-sudo-fix
└── spawny#0.0.1 (cmdify#0.0.4)
Dylans-MBP:Ionic Projects Dylan$ sudo npm-sudo-fix
chown: /users/root/.npm: No such file or directory
Edit (28 August 2018):
I wrote this post and answer many years ago when I was not very familiar with the terminal. Now that I am more experienced, I can recommend the better solution. It is good practice to avoid unnecessary usages of sudo.
I believe the problem is caused by installing node JS from the installer from the node JS website. This version of node JS seems to write various files in the filesystem as root, potentially (and unnecessarily) causing global packages to require root permissions to be installed.
The ideal solution would be to completely remove node JS, that was installed from the node JS installer from the website, from your machine (see https://stackabuse.com/how-to-uninstall-node-js-from-mac-osx/). Then install node from a commandline package manager, such as homebrew.
Original Answer (2016)
Finally came up with a solution by playing with the permissions! Hopefully I didn't stuff up anything. (I am a terminal noob btw.) Anyway, here's the solution.
Run this code here in the terminal (you may or may not have to run cd .. before hand)
sudo chown -R $USER /usr/local/
This changes the permissions of every thing inside the local folder (hence the -R which means recursive). (I found this line somewhere in the ionic forums).
Now, you have to reinstall cordova and ionic
sudo npm install -g cordova
sudo npm install -g ionic
For me anyway, after I do this, I can type ionic and not get any errors. I get this in the terminal if I run cordova though.
/usr/local/lib/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:53
throw err;
^
Error: EACCES: permission denied, open '/Users/Dylan/.config/configstore/update-notifier-cordova.json'
You don't have access to this file.
What I did to fix this was do this (after opening up a new terminal window):
sudo chown -R $USER Dylan
(Dylan is my user folder; replace it with yours. Also, you may have to do a cd .. before running that line And that fixes the permissions for that config file. Now running cordova works without errors! Woot! That error might come back though, so you have to run that line of code again.
Hope this helps somebody!

"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?

Resources