Unable to create yeoman webapp - node.js

I get this when I try to create a webapp with yeoman.
/usr/local/lib/node_modules/yo/node_modules/insight/node_modules/configstore/configstore.js:66
throw err;
^
Error: EACCES, permission denied '/root/.config/configstore/insight-yo.yml'
You don't have access to this file.
at Object.fs.openSync (fs.js:436:18)
at Object.fs.writeFileSync (fs.js:975:15)
at Object.create.all.set (/usr/local/lib/node_modules/yo/node_modules/insight/node_modules/configstore/configstore.js:56:8)
at Object.Configstore (/usr/local/lib/node_modules/yo/node_modules/insight/node_modules/configstore/configstore.js:19:11)
at new Insight (/usr/local/lib/node_modules/yo/node_modules/insight/lib/insight.js:23:34)
at process.<anonymous> (/usr/local/lib/node_modules/yo/node_modules/insight/lib/push.js:11:16)
at process.emit (events.js:98:17)
at handleMessage (child_process.js:322:10)
at Pipe.channel.onread (child_process.js:349:11)
I googled and I tried the following things, but it didn't help:
chown root /root/.config/configstore/insight-yo.yml
chown myusername /root/.config/configstore/insight-yo.yml
Installed npm-sudo-fix and ran it, and no luck yet.
I am on Debian Wheezy and have npm 1.4.4.

I was facing the same issue. I ran the command below, It fixed my problem:
mkdir -p /root/.config/configstore
chmod g+rwx /root /root/.config /root/.config/configstore

The same issue happened to me, i was in root mode user#. I just get back to normal user$ and it worked. i am using Zorin OS

I was able to fix this by running:
echo prefix = ~/.node >> ~/.npmrc
and
export PATH=$HOME/.node/bin:$PATH
Explanation here:
Error installing yeoman
What does `echo prefix = ~/.node >> ~/.npmrc` mean?
npm / yeoman install generator-angular without sudo

I just fixed it in Windows. I have done three things, which one have fixed it I am not sure.
Run cmd prompt as administrator.
takeown /? this command is equivalent to chown (linux) but for windows.
cacls -cacls /E /T /G :F
simply go in $USER /Users/calvin/.config/configstore/ and make files unhidden.
it worked for me like charm. I have been trying to fix this since many days.

I had the same issue building a meanjs app on Ubuntu and I've fixed this issue using sudo instead of root:
sudo npm install -g yo generator-meanjs bower grunt
Then i could build the app without being asked for password again:
yo meanjs
sudo allows user to act as root without root login, it is more secure to use sudo instead of logging in as root.
sudo vs root - askubuntu

Although the chmod command seemed to work at first, I got a similar error later, for a different folder. But here I found this workaround which fixed that too:
sed -i -e '/rootCheck/d' "${NPM_CONFIG_PREFIX}/lib/node_modules/yo/lib/cli.js"
If yo is run as root, rootCheck will downgrade to UID 1000 (on Linux) or 501 (on OS X). This causes the permission error. But in a docker container, you might want to run as root, so you have no other option.
You need to rerun this command after upgrading yeoman. In case NPM_CONFIG_PREFIX is not defined, you can use:
export NPM_CONFIG_PREFIX=$(npm config get prefix)

the issue is that yo is not granted to use some of the nodejs modules. basically, y the problem is related to authorization of yo by node package manager "npm", to fix this run this command first
sudo npm install --global yo --allow-root

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

How to reverse "sudo chown -R 501:20"

Ran npm i -g {library} inside my project and npm gave me an error because I didnt use sudo. instead of using sudo on a second attempt, I followed npm's suggestion to run sudo chown -R 501:20 "/Users/vorousjames/.npm" (inside my project).
now anytime I run an npm command (anywhere), I get bash: /Users/vorousjames/.npm-global/bin/npm: No such file or directory
How do I fix this so I can use npm again?
try running this in the terminal
export PATH="/Users/vorousjames/.npm:$PATH
if it works add that to your .bash_profile

npm update check failed

Last night I tried to update my node and npm, it seemed to have been successful, however ever since then I have been getting this same error any time I try and run any npm command.
I have tried uninstalling and re-installing npm, but cannot get past this error message below.
Node version: v8.3.0
Error message I am getting:
┌───────────────────────────────────────────────────────────────────┐
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /Users/veritystothard/.config │
└───────────────────────────────────────────────────────────────────┘
module.js:491
throw err;
^
Error: Cannot find module 'proto-list'
at Function.Module._resolveFilename (module.js:489:15)
at Function.Module._load (module.js:439:25)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/config-chain/index.js:1:79)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
I'm not sure what other details to include here, if anyone has had this issue before I'd appreciate your help. Thanks!
Following is the answer from github
Fix for windows, I got this message :
npm update check failed Try running with sudo or get access to the
local update config store via sudo chown -R $USER:$(id -gn $USER)
C:\Users.config
so I went on to C:\Users.config and deleted the
"configstore" folder. once I done this, next time a ran npm start, the
folder was re-generated, and error stopped
Fix for OSX:
After two hours of try-and-fail I managed to solve the issue as follows:
go to folder /usr/local/lib/node_modules/
right-click on the folder node_modules > go to Get Info
update the permissions > add yourself and administrator account and set "read and write" for both
run in the terminal "npm install packageName"
if you still get the error, go to the same folder /usr/local/lib/node_modules/ and within the folder node_modules, update in the same way the permissions for the new package folder
try to run again in the terminal "npm install packageName"
That worked for me! Hope it could help somebody.
I had the same issue on AWS server, i used this command to update the config permissions and the npm command worked smooth.
sudo chown -R $USER:$(id -gn $USER) ~/.config
If your are on macOS, you must update the config file. You just have to enter this command in your terminal:
sudo npm i -g npm
I have similar error after node updating so i just delete directory .config and this help.
Run below command from a command prompt
Step 1 : (If possible open cmd as administrator)
- npm install -g npm-check-updates
Step 2 :
- Open new command prompt and Create a new project
I got a Windows 10 environment:
For me, first I did make sure all node.exe instances killed:
taskkill /t /f /im node.exe
Then I've updated npm to the latest version using npm-check-updates
Finally, I deleted .config folder from user home C:\Users\<USERNAME>
That's solved my problem.
If you don't want to chown your entire .config directory (which contains configuration files from other programs), try:
sudo chown -R $USER:$(id -gn $USER) "/home/skaestle/.config/configstore/"
Try running the command prompt Run as administrator mode, if that not solved your issue delete the .config folder under c:\user\<name of the user>\ and then try running the command prompt Run as administrator mode.
I had the same error (npm update check failed) on a Centos 7 but not when installing node, just when loggin into the server and it was because there was no more space left. Deleted some files, updated the system and everything worked fine again.
Just in case somebody else comes to the same problem.
I have a fixed that worked for me on OSX Catalina:
-------------------------------------
/var/log/nodejs/nodejs.log
-------------------------------------
> node server.js
€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /tmp/.config │
└──────────────────────────â”
I ran the following code in the terminal and as suggested here: sudo chown -R $USER:$(id -gn $USER) /tmp/.config & redeployed to my instance which still showed a degraded state.
I did this several times and this did not result in success.
Since I had a duplicate instance that was in the ready, so I didn't think it was a permissions problem on my local machine.
The following fix worked for me (please note that my code is deployed to ebs through AWS CodePipeline":
Delete package-lock.json from your express/node project.
Run npm i
git add && git commit -m "your commit msg" && git push
In your aws console, go to code pipeline and verify your code deployed successfully.
Navigate to Elastic Beanstalk. If your code pushed successfully, you should see your instance updating.
After this the state of your EBS environment should be in the ready state.
Hope this helps someone out.
worked for me after running below command
nvm use --delete-prefix version
Running the cmd with admin rights once was enough for me.
Just did npm version.
After that it worked again also without admin rights.
I did not delete anything.
{
npm: '6.13.6',
node: '12.14.1',
...
}
If the user does not have sudo rights in a unix environment, remember the user name you want to issue the command with (-> USER). Then use
su
Enter your root password. Then
chown -R USER:USER .config
Other .config folders that were created using root are also changed. In my case changing ~/.config/nvws owner did the job (chown -R THE USER YOU USE NPM WITH:THE USER YOU USE NPM WITH .config/nvm)
I'm a windows user. I solved mine by going to the /Users/<username> right clicking the .config folder then in properties un-ticked the read only and apply
run script to check for update
sudo npm install -g npm-check-updates
and later update using sudo npm
This issues come due to TWO reasons
You have no permission to read-write
Due to window settings folder is secured.
case 1st- just enable the read-write permission
case 2nd- if u have permission for read-write and still you facing the same issues, it means you system securities reject the request to write the file, because the file location is given in C drive
solution - JUST disable the firewall / Ransomware protection in windows 10. try again you will get the success.

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!

Permissions Denied in Terminal

So I am a little new to working in the terminal and trying to set up yo and a localhost environment. No matter what I do it keeps throwing a permissions denied error. I have installed node and npm already and when I run the yo install
npm install -g yo bower grunt-cli gulp i get this error message. My buddy and I have tried so many different things to fix this but we cant get anywhere. I can access and run using sudo but I need to actually have the permissions to get this working. Help please?
I am sorry if that is not detailed enough, I am new to working in the terminal and may not know entirely what I am doing. If all else fails I was going to reset my desktop to factory settings and start over with setting my users and groups.
Screenshot of errors Here
sudo chown -R `whoami` /usr/local
or
npm install npm -g
...will do the trick.
You're not the first one to experience those problems and they are (finally) actively addressed in npm#3.X.X

Resources