mean.io initialising new project - owner rights - node.js

I'm trying to initialise my first MEAN project with command mean init myProject. This command returns the error :
There are 1313 files in your ~/.npm owned by root
Please change the permissions by running - chown -R whoami ~/.npm
By running this chown command I have another error Operation not permitted.
I tried to use nvm but I'm not sure if it's a good direction. If yes I have no idea how to configure it.
Could you please help me with that, I'm struggle with it since couple of days :/ Thanks

You need to run chown as root. Get your username using
whoami
Then run this replacing <username> with the one you got in the previous step
sudo chown -R <username> ~/.npm
For future reference, don't run "npm install -g" commands with sudo. If you're having permission problems, fix those first.

I had really serious problems with mean.io framework/scaffolding tool.
I know, that isn't solution for your problem but please be so kind to consider yeoman.

Related

How can I undo the (potentially) dangerous fix for npm's EACCESS?

Yesterday I tried installing yarn via npm, however was provided with an EACCES errno -13 message.
I followed this guide that recommended 2 fixes in Terminal:
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modules/
Whilst they fixed the issue, the comments section of the article indicate this fix is a bit dangerous (I only saw the comments after I had made the changes). How can I undo the 2 changes that I made yesterday so I can find an alternative/safer solution?

why do I have to write Sudo every time in ubuntu

I'm creating a react app, using command
create react-app new-app
but it's not creating a new app until i change this command to
sudo create react-app new-app.
After this if I try to install any dependency using npm then also I have to include sudo in the beginning of every command.
And also sometimes the project files are not accessible by code editor as they get locked .
please help me to get rid of this sudo ...
Sudo used to stand for "Superuser do" It simply means that your operating system thinks that you don't own the directory. You can use this command to resolve the issue: chown [username]:[username] -R. chown is short for "Change Owner".
Here's a trick you could use in the future - incase you have to execute the previous command using sudo you can punch in sudo !! and this will run the previous command as root.
So how that would work is:
some command - Doesn't run and you need sudo.
sudo !! - executes sudo some command automatically.
Best wishes :)

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

Using SUDO with NVM?

How is it to execute something like sudo npm rebuild or sudo node if Node.js was installed by NVM ?
Each time I type sudo command, my console tries to execute npm or node program in /usr/bin/ or /usr/lib, neither of which do exist.
Try creating symlinks in /usr/bin or /usr/lib. Not a strong solution, but may be enough.
sudo ln -s /home/denny/.nvm/versions/node/v0.12.0/bin/npm /usr/bin/npm
sudo for writing in system location. Suggestions here may happen useful, especially rvmsudo or group access.
Other suggestion:
According to comment, you may try to create a bash script at /home/denny/npm.sh:
#!/bin/bash
PTH="/home/denny/.nvm/versions/node/$(node -v)/bin/npm"
$PTH
chmode it +x properly and create symlink with this:
sudo ln -s /home/denny/npm.sh /usr/bin/npm
Should always check for node -v and run npm from proper directory.
I needed to do this to run the Atom installation script, but I didn't want to permanently change my machine setup. So, I did:
sudo bash
and then I sourced the nvm.sh file in my user's home directory tree:
source /home/ada-lovelace/.nvm/nvm.sh
That let me run the necessary commands with root. Of course, this means the very next time I need to run node in a session with root I'll have to do these steps again, but I don't anticipate needing to do this in the near future.

Unable to create yeoman webapp

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

Resources