I am using a windows 8.1 maching,and trying to install the Bower automation tool via Git Bash. So what I found is this:
$ npm config set prefix /usr/local
$ npm install -g bower
$ which bower
>> /usr/local/bin/bower
However after typing the first command gitbash gives me this.
Error: EPERM: operation not permitted, mkdir 'C:\Program Files\Git\usr\local'
at Error (native)
Why is this happening?
Thanks.
Related
I am having an issue running my node application on a different computer than the one I usually use. After a lot of troubleshooting:
The error message I'm getting is:
Error: ENOENT: no such file or directory, scandir '.../node_modules/node-sass/vendor'
A posting that I was reading suggested that I run sudo npm install -g node-sass, which gives me the following error:
Error: EACCES: permission denied, mkdir '...nvm/versions/node/v8.9.0/lib/node_modules/node-sass/build'
I then tried to run sudo npm rebuild node-sass but I'm getting the same error message:
Error: EACCES: permission denied, mkdir '.../node_modules/node-sass/build'
I then ran sudo npm install -g node-sass --unsafe-perm=true --allow-root but it also didn't work:
ENOENT: no such file or directory, scandir '.../node_modules/node-sass/vendor'
What am I doing wrong here? Why isn't node-sass working? Why isn't sudo working properly?
Windows. Try below
node node_modules/node-sass/scripts/install.js
npm rebuild node-sass
Most probably it's not node-sass issue. This sometimes happens when you use different OS to install node-sass. As it uses some native components, the npm install must only be done one OS. Do not copy node_modules from some other place. Do a fresh install.
Have you tried deleting the node_modules directory and running npm install again?
Are you working on Windows machione where the npm install was done using a Ubuntu shell (inside windows) and now you are trying to install again from the windows command line? If so, dont. Use only one shell.
Finally if none of these help, then its possible a user permission issue. Check if you can get super user access sudo su - and then try doing a fresh npm install.
Your user does not has the rights to write in the folder you are trying. You are using 3 ... so it goes to the folder /Users on the second one you have ...nvm/versions/node/v8.9.0/lib/node_modules
This is because of a missing node-sass dependency or broken node-sass package issue.
You can resolve this by the following steps:
Install node-sass globally, if it is not installed in your system.
npm install -g node-sass
Open command prompt/terminal on the project root directory and execute the following commands.
nodejs node_modules/node-sass/scripts/install.js
npm rebuild node-sass
I attempted to do a sudo npm install -g appium on Mac OS 10.12.5.
I get this error:
info Chromedriver Install Installing Chromedriver version '2.30' for platform 'mac' and architecture '64'
info Chromedriver Install Opening temp file to write chromedriver_mac64 to...
Error: EACCES: permission denied, mkdir
'/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/2017820-44752-12jfqpb.z2hd'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! appium-chromedriver#3.0.1 install: node install-npm.js
npm ERR! Exit status 1
npm ERR!
this is not a dup question, as this install attempt was with sudo, as the other one was not.
sudo npm install -g appium --unsafe-perm=true --allow-root
Worked for me
you are using npm so you have to use
sudo npm install --unsafe-perm
In unsafe mode with every command you run
hopefully, it will help
The -g option means install globally. When packages are installed globally, EACCES permission errors can occur.
Consider setting up npm to operate globally without elevated permissions. See Resolving Permission Errors for more information.
Option 1
The best way to avoid permission issues is to reinstall NodeJS and npm using a node version manager.
1. Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
You can close and reopen the terminal ou just open another terminal and check if nvm is installed properly with this command: command -v nvm.
2. To download and install the latest LTS release of NodeJS, run:
nvm install --lts
3. Set the newly installed NodeJS as the default environment:
nvm alias default lts/*
Option 2 (Does not apply for windows)
Change the owner of npm's directories to the current user:
sudo chown -R $(your_user) /usr/local/{lib/node_modules,bin,share}
sudo chown -R $(your_user) ~/.npm ~/.npmrc
I reinstalled Node/NPM. Problem solved.
I think this is a new issue & took me couple hours to figure it out:
$ brew install node -v
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/node- 0.10.31.mavericks.bottle.tar.gz
..
npm ERR! Error: EACCES, mkdir '/../.npm/nopt/2.1.2'
npm ERR! { [Error: EACCES, mkdir '/../.npm/nopt/2.1.2']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
Issue of installing npm was solved by (thanks to https://github.com/Homebrew/homebrew/issues/28501#issuecomment-53907840):
$ brew update
$ sudo chown -R $USER /usr/local
but this messed up my system. I was not able to use 'sudo' any more till I run Repair Disk Permissions in Disk Utilities.
changing ownership of those system libraries to your end user account is NOT safe - additionally web servers should NEVER be owned by root for known security reasons and so goes for node - you have rendered your box open to evil
Here is a safe way to install node/npm on OSX/linux
to start fresh remove prior node.js and npm installs as well as these :
sudo mv ~/.npmrc ~/.npmrc_ignore
sudo mv ~/.npm ~/.npm_ignore
sudo mv ~/tmp ~/tmp_ignore
sudo mv ~/.npm-init.js ~/.npm-init.js_ignore
to install nodejs and npm as yourself NOT root do these commands (linux) :
mkdir ${HOME}/bin
download source from : http://nodejs.org/download/
cd node-v0.10.31
./configure --prefix=${HOME}/bin/nodejs
make -j8
make install
which puts it into dir defined by above --prefix
export PATH=${HOME}/bin/nodejs/bin:$PATH
NODE_PATH so node can find dir for modules otherwise
npm install xxx will put newly installed module into dir in curr dir :
export NODE_PATH=${HOME}/bin/nodejs/lib/node_modules
do above AND use syntax : npm install xxxxx -g
always use the -g for global
nodejs install gives you npm as well :
ls -la ${HOME}/bin/nodejs/bin
Here's what I've done so far:
brew install nodejs npm
npm install -g grunt
I've also set up my path to include the proper directories. When I run echo $PATH I get:
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/lib/node:/usr/local/lib/node_modules:/usr/local/share/npm/bin:/usr/local/share/npm/lib/node_modules:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/landonschropp/.rbenv/shims:/usr/local/sbin:/usr/local/lib/node:/usr/local/lib/node_modules:/usr/local/share/npm/bin:/usr/local/share/npm/lib/node_modules:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
The installation succeeds without any problems. However, if I try to run grunt I get this error:
zsh: permission denied: grunt
Did I miss a step?
Try installing the command line interface:
npm install -g grunt-cli
sudo npm install -g grunt-cli and then type your password.
i have this error when try to install coffee-script using this command:
npm install -g --verbose coffee-script opal
these are the error message:
npm ERR! Error: EACCES, symlink '../lib/node_modules/coffee-script/bin/coffee'
npm ERR! { [Error: EACCES, symlink '../lib/node_modules/coffee-script/bin/coffee']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '../lib/node_modules/coffee-script/bin/coffee' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm info postuninstall opal#0.3.2
npm ERR! Error: EACCES, symlink '../lib/node_modules/opal/bin/opal-node'
npm ERR! { [Error: EACCES, symlink '../lib/node_modules/opal/bin/opal-node']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '../lib/node_modules/opal/bin/opal-node' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
the folder /usr/local/bin and /usr/local/lib/node_modules are owned and writable by current user, and i do not want to run that npm command using root, how to know which folder that the npm tried to make a symlink to?
i'm using npm 1.2.9-1chl1~quantal1 and nodejs 0.8.19-1chl1~quantal1
your node installation uses system directories. Use sudo when using -g
sudo npm install -g --verbose coffee-script opal
You can chown NPM's bin to your user name with this one liner to solve this problem:
$ chown -R `whoami` `npm -g bin`
ah, using this command:
npm -g bin
it would output something like this:
/usr/bin # this is the folder nodejs wanted to write..
then you may chmod or chown it so it can be written for installation.
I had a similar problem at NPM modules won't install globally without sudo, the issue was that when i installed node i did it with sudo via chris/lea ppa repo.
My solution was to uninstall node and then install it this way:
Download latest stable node sources from nodejs.org #in my case node-v0.10.20.tar.gz
tar -zxf node-v0.10.20.tar.gz #uncompress sources
cd node-v0.10.20 #enter uncompressed folder
sudo chown $USER -R /usr/local
./configure --prefix=/usr/local && make && make install
PD: If you don't want to change ownership of the /usr/local folder, you can install it somewhere you already own. The problem of this approach is that you will have to bind the installation folder with the bash command line so that we can use the node command later on
mkdir ~/opt
./configure --prefix=~/opt && make && make install
echo 'export PATH=~/opt/bin:${PATH}' >> ~/.bashrc #or ~/.profile or ~/.bash_profile or ~/.zshenv depending on the current Operative System
With either of those approaches, you will be able to do the following without using sudo
npm install -g --verbose coffee-script opal
Had a similar problem. Turns out I had something in project/node_modules directory installed with sudo. In my case it was some of the dependencies AND ALSO .bin directory. I deleted these bad directories, then ran npm install again and it succeeded. I did also reinstall global protractor and phantomjs, but not sure if that was required. I am sure it was the bad (i.e. root-owned) .bin directory causing this.