When I run npm install -g composer-cli I get this error:
"Need to have composer-cli installed at v0.15 or greater".
How can I resolve that?
Try running the command with --unsafe-perms , like this:
sudo npm install --unsafe-perm -g composer-cli
Reference: https://github.com/nodejs/node-gyp/issues/454
On Ubuntu (the supported Linux development environment) we do not recommend using sudo to install Composer.
The usual reason people would resort to sudo is a permission problem, but it is better to resolve the permission problem rather than use sudo. Often the problem is the npm prefix which can get set to /usr/local to which the user doesn't have write access. Issuing an npm config set prefix /home/<myuser>/ will solve the problem.
You may have an old version of Composer or one of the components installed. Try using npm ls -g --depth=0 to see if you have some composer code already installed, and if so remove it with npm uninstall -g composer-<component> where might be cli, or playground etc. The retry the install-g command.
Try this....this is the command to install 0.20 version.
npm install -g composer-cli#0.20
I changed my node version from
11
to
8.8.15
and did npm install -g composer-cli.It worked for me .
You need to use a 8.* node version,
My solution was:
nvm install 8.9.0
nvm use 8.9.0
npm install -g composer-cli
I'm building my first project in Laravel and trying to use Elixir, using homestead on Windows 8.1. I've hit the known npm/vagrant issue of too-long-path-names:
https://harvsworld.com/2015/how-to-fix-npm-install-errors-on-vagrant-on-windows-because-the-paths-are-too-long/
So I made the one line edit recommended in that article (thank god for that guy), and then ran (with and without sudo):
npm install --no-bin-links
It's moved me ahead so now I get two different kinds of errors: some 'Missing write access' errors, and a bunch of "EACCES" errors:
The error output gives me my next clue in the scavenger hunt (I think):
Please try running this command again as root/Administrator
That brings me to this post, but the difference for me is there's no change even after I use sudo (or update my user permissions like so):
sudo chown -R $USER /usr/local
sudo chown -R $(whoami) ~/.npm
Update: then after the suggestion below I get EPROTO and EXTXTBSY errors (even after following the prompted suggestion to rename the npm-debug.log back:
So I tried running gulp to see if it would give me clues, and error output had me do:
sudo npm rebuild node-sass
Running that gives me the same EPROTO and ETXTBSY errors, and the npm-debug.log file shows:
error EPROTO: protocol error, symlink '../node-sass/bin/node-sass' -> '/home/vagrant/Code/Family-laravel/node_modules/laravel-elixir/node_modules/gulp-sass/node_modules/.bin/node-sass'
Then after working on some other stuff for an hour I came back fresh and redid these steps, this time getting way fewer errors:
sudo npm -g install npm#latest (fine)
sudo npm install --no-bin-links (just the ETXTBSY error and an error in plugin 'run sequence', in task 'sass')
sudo npm rebuild node-sass --no-bin-links (no errors!)
gulp (just one error: not found: notify-send)
Getting closer!
I have been trying to figure out this problem for weeks. Here is what I did to make it work without using my host environment:
I updated node to the latest version in homestead according to nodesource.com:
sudo apt-get install --yes nodejs
curl --silent --location https://deb.nodesource.com/setup_4.x | sudo bash -
I updated npm to the latest version in homestead. This should be done after updating node:
sudo npm -g install npm#latest
I ran npm install in the laravel project directory. I also had to use force to get all of the dependencies to install:
sudo npm install --no-bin-links
sudo npm cache clear
sudo npm install --force --no-bin-links
I rebuilt node-sass according to a gulp error:
sudo npm rebuild node-sass --no-bin-links
During this whole process if something fails or after each install, i used:
sudo npm cache clear
My host is windows 10, with latest virtualbox, latest vagrant, latest homestead. I used git bash as administrator and ssh into vagrant using git bash.
So far I have only tested and confirmed that my gulp works. It is possible that other dependencies need to be rebuilt.
Hope this helps!
As many of you that are also setting up Homestead with Virtual Box...
After googling for a solution I decided to refer back to the Laravel Homestead documentation. Fortunately the solution was posted there:
https://laravel.com/docs/5.8/homestead#provider-specific-settings
You just need to add the following to your homestead Vagrantfile.
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
(...)
config.vm.provider "virtualbox" do |v|
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
(...)
end
IMPORTANT
Don't forget to provision as an administrator.
homestead up --provision
I had same problem. I did below. It works fine.
npm install --no-bin-links
The cause of your initial EACCES error was that you used sudo without using the -H option. NEVER use sudo npm. ALWAYS use sudo -H npm.
The instructions on the Internet everywhere (including NPM docs) are simply wrong.
I solved my issue with the solution described here: https://www.prolificinteractive.com/2015/01/21/getting-vagrant-nodejs-windows-play-well-together/
The main trick was in:
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/path/to/guest/shared/directory", "1"]
Hope it helps someone
Here is how I solved the similar problem on VirtualBox:
# My Virtualbox image name "centos"
# My shared folder name: localdev
# My mounted directory name on virtualbox: /data
VBoxManage setextradata "centos" VBoxInternal2/SharedFoldersEnableSymlinksCreate/data 1
VBoxManage setextradata "centos" VBoxInternal2/SharedFoldersEnableSymlinksCreate/localdev 1
## see above how i added image name with quotes + my folder names before 1
# I made sure I am running VirtualBox in Administrator Mode
# Boot up the VM and install this:
yum install yarn
# navigate to your code folder and run:
yarn install
I keep having this problem so I uninstalled homebrew and tried to uninstall npm, but it did not work. I installed homebrew again and then typed "brew install npm." It returned "Warning: node-0.12.7 already installed." I then tried to use npm with the following command: "npm install -g mup" and it returned "-bash: npm: command not found."
I have trouble uninstalling npm because on the site it uses npm to uninstall npm... Otherwise, it denies me permission. How can I get around this so that I can install mup with "npm install -g mup"? What's weird is that it was working earlier but now it is failing me. Thank you.
Try this
cd ~
sudo rm -rf .npm
brew update
brew uninstall npm
brew install npm
Currently I always run sudo npm install <package-name> but as I understand it's not correct.
I want to have opportunity not to use it as root/Administrator.
I followed some advice and used this command sudo chown -R <username> ~/.npm but it won't work...
for example, it's an output of my npm install jade
...
npm http 200 https://registry.npmjs.org/amdefine
npm http GET https://registry.npmjs.org/amdefine/-/amdefine-0.0.5.tgz
npm http 200 https://registry.npmjs.org/amdefine/-/amdefine-0.0.5.tgz
npm ERR! Error: EACCES, symlink '../jade/bin/jade'
npm ERR! { [Error: EACCES, symlink '../jade/bin/jade'] errno: 3, code: 'EACCES', path: '../jade/bin/jade' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
as you see download started successfully but then failed..
I'm wondering what is the best way to disallow sudo on npm?
It's possible (and advisable) to npm install -g node modules without sudo.
Check the permission of your /usr/local/share/npm/bin folder. I had installed node and npm through brew (without sudo) and that particular folder ended up being owned by root.
This fixed it for once and for all:
$ sudo chown $(whoami) /usr/local/share/npm/bin
(As for disallowing sudo with npm: you'd have to tweak npm for that. Your own node code could make use of https://npmjs.org/package/sudo-block, npm install sudo-block)
EDIT: even though this works, I no longer use -g. Instead use prefix (see next answer), or better yet use NIX https://unix.stackexchange.com/a/381797 (even on OSX)
In my opinion is the cleanest way to specify the npm prefix:
npm config set prefix ~/.node_modules
And then to add the following to you .bash_profile
export PATH=$HOME/.node_modules/bin:$PATH
Now the packages will install into your user directory and no permissions will be harmend.
EDIT: If you can't install yeoman, create a bash file in one of your PATH directories named yodoctor with the following contents
#!/bin/bash
yo doctor
Make the file executable with
chmod +x yodoctor
And now you should be able to install yeoman.
You can also do:
sudo chown -R $USER /usr/local
and recursively change the files to your current user.
I have found this to be a better solution
sudo chown -R $USER /Users/$USER
This will just change the owner of your user to you and npm should be installed under your user on OS X.
Everything that I have been reading says sudo for npm installs is bad and I would have to agree with them as you open yourself up to malicious scripts.
The two solutions offered here are are not something I would recommend because they are brute force solutions. Instead, I recommend reading One does not simply sudo npm
I'm trying to install node.js via Homebrew. Unfortunately, I get this error:
➜ ~ brew install node
==> Downloading http://nodejs.org/dist/v0.8.10/node-v0.8.10.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/node/0.8.10
==> make install
==> Caveats
Homebrew installed npm.
We recommend prepending the following path to your PATH environment
variable to have npm-installed binaries picked up:
/usr/local/share/npm/bin
Warning: Could not link node. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link node'
==> Summary
/usr/local/Cellar/node/0.8.10: 856 files, 13M, built in 103 seconds
So then I try to link node manually...
➜ ~ brew link node
Linking /usr/local/Cellar/node/0.8.10... Warning: Could not link node. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/node/0.8.10/lib/node_modules/npm/scripts/relocate.sh
Target /usr/local/lib/node_modules/npm/scripts/relocate.sh already exists. You may need to delete it.
To force the link and delete this file, do:
brew link -f formula_name
To list all files that would be deleted:
brew link -n formula_name
No luck, so I try forcefully linking node...
➜ ~ brew link -f node
Linking /usr/local/Cellar/node/0.8.10... Warning: Could not link node. Unlinking...
Error: Permission denied - /usr/local/lib/dtrace/node.d
I'm not familiar with dtrace in any regard and I'm afraid to mess with permissions, so I tried to sudo..
➜ ~ git:(master) sudo brew link -f node
Password:
Error: Cowardly refusing to `sudo brew link'
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.
I've tried uninstalling node via brew uninstall node and retrying the install with no luck.
I run Mac OS X Mavericks. I tried to install node 0.10.25 and the top answer did not work for me.
natevw says to rm -rf /usr/local/lib/node_modules/npm but if the permissions on /usr/local/lib/node_modules look like this:
drwxr-xr-x 3 root admin 102 Feb 2 20:45 node_modules
then brew will not be able to create its npm symlink in that directory. Here's my solution:
Step 1: Update Homebrew
$ brew update
Step 2: Remove node/npm everywhere on your system
Some of these commands are not necessary depending on how you installed node/npm in the past.
$ brew uninstall npm
$ brew uninstall node
$ npm uninstall npm -g
$ sudo rm -rf /usr/local/lib/node_modules
Note: I had stray node files that I found by running brew -v link node (which gave me the verbose output of the linking errors brew was complaining about). You may need to:
$ sudo rm -rf /usr/local/include/node
$ sudo rm -rf /usr/local/lib/node
Step 3: Open a new terminal and install node
$ brew install node
The homebrew package for node.js now includes npm again, so this happened to me when I missed the homebrew package's message about removing the standalone version first.
Assuming, like me, you've already broken node/npm by attempting the upgrade before knowing to npm uninstall npm -g first, you can rm -rf /usr/local/lib/node_modules/npm and then brew link node. This removes the standalone self-hosted npm package (rather than the one brew would like to install) and lets brew symlink its bundled one from Cellar.
sudo chown -R $(whoami) /usr/local
would do just fine as mentioned in the brew site troubleshooting
https://github.com/Homebrew/homebrew/wiki/troubleshooting
You probably already installed an older version of node.js using a different method, so you need to manually remove the files that are getting in brew's way.
Do brew link -n node and manually delete those conflicting files and directories, then try brew link node again.
I'm a bit late, what worked for me was this:
* npm uninstall npm -g
* brew uninstall node
* brew install node
* sudo rm -rf /usr/local/lib/dtrace/node.d
* brew link node (caused error with permissions)
* sudo chmod 777 /usr/local/lib/dtrace/node.d
* brew link node
Everything was successful after this sequence
Try this. Got from another reference and worked for me.
brew uninstall node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R $(whoami) /usr/local
brew link --overwrite node
brew postinstall node
I had the same problem after transferring all my applications from my old Mac to my new one.
I found the solution by running brew doctor :
Warning: Broken symlinks were found. Remove them with brew prune
After running brew prune, Homebrew is finally back on track :)
My problem had a slightly different solution.
The directory in which brew wanted to create the symlinks were not owned by the current user.
ls -la /usr/local/bin/lib/node | grep node yielded:
drwxr-xr-x 3 24561 wheel 102 May 4 2012 node
drwxr-xr-x 7 24561 wheel 238 Sep 18 16:37 node_modules
For me, the following fixed it:
sudo chown $(users) /usr/local/bin/lib/node_modules
sudo chown $(users) /usr/local/bin/lib/node
ps. $(users) will get expanded to your username, went a little out of my way to help out lazy copy pasters ;)
thx #suweller.
I fixed the problem:
➜ bin git:(master) ✗ brew link node
Linking /usr/local/Cellar/node/0.10.25... Warning: Could not link node. Unlinking...
Error: Permission denied - /usr/local/lib/node_modules/npm
I had the same problem as suweller:
➜ bin git:(master) ✗ ls -la /usr/local/lib/ | grep node
drwxr-xr-x 3 24561 wheel 102 11 Okt 2012 node
drwxr-xr-x 3 24561 wheel 102 27 Jan 11:32 node_modules
so i fixed this problem by:
➜ bin git:(master) ✗ sudo chown $(users) /usr/local/lib/node_modules
➜ bin git:(master) ✗ sudo chown $(users) /usr/local/lib/node
after i fixed this problem I got another one:
➜ bin git:(master) ✗ brew link node
Linking /usr/local/Cellar/node/0.10.25... Warning: Could not link node. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/node/0.10.25/lib/dtrace/node.d
Target /usr/local/lib/dtrace/node.d already exists. You may need to delete it.
To force the link and overwrite all other conflicting files, do:
brew link --overwrite formula_name
To list all files that would be deleted:
brew link --overwrite --dry-run formula_name
So I removed node.d by:
➜ bin git:(master) ✗ sudo rm /usr/local/lib/dtrace/node.d
got another permission error:
➜ bin git:(master) ✗ brew link node
Linking /usr/local/Cellar/node/0.10.25... Warning: Could not link node. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/node/0.10.25/lib/dtrace/node.d
/usr/local/lib/dtrace is not writable. You should change its permissions.
and fixed it:
➜ bin git:(master) ✗ sudo chown $(users) /usr/local/Cellar/node/0.10.25/lib/dtrace/node.d
and finally everything worked:
➜ bin git:(master) ✗ brew link node
Linking /usr/local/Cellar/node/0.10.25... 1225 symlinks created
the ultimate answer: change the owner of that directory to whoever you are
sudo chown -R `whoami` /usr/local/include
which is also recommended by brew if you run brew doctor
Most brew install issues with node are caused by permission errors or having node previously installed and then trying to install it via brew. The solution that worked for me finally was:
WARNING: This will uninstall nodejs (multiple versions) use with caution:
Remove node via brew:
brew uninstall node
also did via force:
brew uninstall node --force
To use the script Source: Remove node:
curl -O https://raw.githubusercontent.com/DomT4/scripts/master/OSX_Node_Removal/terminatenode.sh
Then:
chmod +x /path/to/terminatenode.sh
Then:
./terminatenode.sh .
Then make sure to do the following command:
chown $USER /usr/local
Then do a brew update (keep doing this until all things are updated):
brew update
Clean brew up and run update again (might be redundant) and run doctor to make sure things are in place:
brew cleanup; brew update; brew doctor
And finally install node via brew (verbose):
brew install -v node
I was getting an error while installation that not able to link node and /usr/local/include is not writable
Below solution worked for me :-
First create the include folder, note that this requires sudo privileges
cd /usr/local
sudo mkdir include
sudo chown -R $(whoami) $(brew --prefix)/*
brew link node
I also managed to mess up my NPM and installed packages between these Homebrew versions and no matter how many time I unlinked / linked and uninstalled / installed node it still didn't work.
As it turns out you have to remove NPM from the path otherwise Homebrew won't install it: https://github.com/mxcl/homebrew/blob/master/Library/Formula/node.rb#L117
Hope this will help someone with the same problem and save that hour or so I had to spend looking for the problem...
by the Finder, Delete this file:
/usr/local/lib/dtrace/node.d
in terminal:
$ brew link --overwrite --dry-run node
then:
$ brew link node
I have tried all of the methods and none of them works.
The easiest way is to reinstall node from https://nodejs.org/en/download/
Simply download the pkg and install it.
Now I have a working npm and node again.
Don't know, if it's a good idea or not: After trying all other solutions without success, I just renamed /usr/local/lib/dtrace, linked node and re-renamed the directory again. After that, node worked as expected.
I was struggling with this for a while. (for me "npm uninstall npm -g" did nothing)
I tried a bunch of things:
npm uninstall npm -g
brew uninstall node
brew install node
I was still having some issues and was getting errors when i tried to link the node files
Finally i tried this
brew link --overwrite node
That seemed to have fixed it. (it overwrites al the conflicting files and also links node and npm)
Hope this helps
I completely uninstalled brew and started again, only to find the same problem again.
Brew appears to work by symlinking the required binaries into your system where other installation methods would typically copy the files.
I found an existing set of node libraries here:
/usr/local/include/node
After some head scratching I remembered installing node at the date against this old version and it hadn't been via brew.
I manually deleted this entire folder and successfully linked npm.
This would explain why using brew uninstall or even uninstall brew itself had no effect.
The highest ranked answer puts this very simply, but I thought I'd add my observations about why it's necessary.
I'm guessing a bunch of issues with other brew packages might be caused by old non-brew instances of packages being in the way.
Had been wrecking my head on symlinking node .. and nothing seemed to work...but finally what worked is setting the right permissions . This 'sudo chown -R $(whoami) /usr/local' did the work for me.
I fixed this in El Capitan by using the following command. Honestly, no idea what it does, but thought I'd share since it fixed my problem.
brew link --overwrite node
You need to remove the npm package manually.
first unlink node: brew link -n node
remove npm folder: rm -R /usr/local/Cellar/node/0.8.10/lib/node_modules/npm
link again: brew link node
there will be a soft link to the new location of npm