Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cbrauckmuller's avatar

ERR! EEXIST when trying to npm install Laravel Elixir

Seriously tearing my hair out with this one. Node and Gulp are installed, and I can issue the "npm install" command fine. However the install process is taking upwards of 10 minutes and every time, it hangs on this error, unbuilds everything and then fails. What am I doing wrong?

npm verb about to build /home/vagrant/Sites/facade-forward/webapp/node_modules/laravel-elixir/node_modules/gulp-sass/node_modules/node-sass
npm verb about to build /home/vagrant/Sites/facade-forward/webapp/node_modules/laravel-elixir/node_modules/gulp-sass
npm verb about to build /home/vagrant/Sites/facade-forward/webapp/node_modules/laravel-elixir
npm ERR! EEXIST, open '/home/vagrant/.npm/504ec022-t-npm-through2-0-6-3-package-tgz.lock'
File exists: /home/vagrant/.npm/504ec022-t-npm-through2-0-6-3-package-tgz.lock
Move it away, and try again. 
npm ERR! System Linux 3.16.0-23-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "laravel-elixir"
npm ERR! cwd /home/vagrant/Sites/facade-forward/webapp
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! path /home/vagrant/.npm/504ec022-t-npm-through2-0-6-3-package-tgz.lock
npm ERR! code EEXIST
npm ERR! errno 47
npm verb exit [ 47, true ]
0 likes
16 replies
cbrauckmuller's avatar

Tried

sudo npm install

...and still no joy, getting the same error as before. To further clarify, I am running Homestead and have tried destroying and rebuilding my VM multiple times. I am running the command from the root directory of my Laravel app after SSHing into my Homestead box. Node is version 0.10.33 and NPM is version 1.4.28, which is what ships with Homestead I believe.

Teimos's avatar

I have this problem too. Maybe it's due to the Windows restriction on the length of the path "Total path and file name length must not exceed 260 characters"?

I tried to install laravel-elixir on Server and copy a zip-archive with node_modules/laravel-elixir to my local app, but has received many errors while unzipping, like this:

Cannot create node_modules\laravel-elixir\node_modules\browserify\node_modules\insert-module-globals\node_modules\combine-source-map\node_modules\inline-source-map\node_modules\source-map\test\source-map\test-source-map-generator.js
    Total path and file name length must not exceed 260 characters

Problem is still relevant.

Teimos's avatar

Found some solution. Maybe not fully correct, but it is works.

Ofcourse, you must "sudo npm install --global gulp" before.

First, download archive with already installed laravel-elixir: https://dl.dropboxusercontent.com/u/34996622/node_modules.zip

Second, configure tmp path in Winrar (Options -> Path) to shortest path (I used E:/winrartmp/) to bypass the "260 limit" error.

Third, extract archive to your app folder.

I got just one error:

Cannot create node_modules\laravel-elixir\node_modules\gulp-sass\node_modules\node-sass\test\fixtures\spec\spec\extend-tests\104_test_nested_extender_counts_extended_subselectors\104_test_nested_extender_counts_extended_subselectors\expected_output.css
    Total path and file name length must not exceed 260 characters

But I think it is not critical. Run "gulp" command to check is all correct.

P.P.S. You may get an error while gulp executed:

gulp-notify: [Error in notifier] Error in plugin 'gulp-notify'
not found: notify-send

Solution that works for me:

sudo apt-add-repository ppa:izx/askubuntu
sudo apt-get update
sudo apt-get install libnotify-bin

Thanks to @Bondacom at https://laracasts.com/discuss/channels/general-discussion/gulp-notify-error-in-notifier-error-in-plugin-gulp-notify-not-found-notify-send

nbj's avatar

Found another solution.

The problem, as stated before, is because VirtualBox handles the long paths in windows funny. Windows does infact support long paths, but VirtualBox apparently does not, out of the box that is. I got this working, but not perfectly, as I would like it to be a bit more seamless, but as a temporary solution until I iron it all out, this will get you going.

What I did was edit the Vagrant driver file, found at:

C:\Program Files\Vagrant\embedded\gems\gems\vagrant-1.7.2\plugins\providers\virtualbox\driver\version_4_3.rb

We need to prepend the shared folder path with \\?\ to make VirtualBox trick the Windows API it uses to allow for longer paths.

Find the method share_folders

def share_folders(folders)
          folders.each do |folder|
            args = ["--name",
              folder[:name],
              "--hostpath",
        folder[:hostpath]]
            args << "--transient" if folder.has_key?(:transient) && folder[:transient]

            # Add the shared folder
            execute("sharedfolder", "add", @uuid, *args)

            # Enable symlinks on the shared folder
            execute("setextradata", @uuid, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{folder[:name]}", "1")
          end
        end

Change the line

    folder[:hostpath]]

to

    '\\\\?\\' + folder[:hostpath].gsub(/[\/\\]/,'\\')]

After this I was able to run npm install from cmd on my host. So if you havn't installed npm on your host, you need to do this. I still got and error while running sudo npm install in the guest, but I am working on fixing this.

Hope this helps a bit.

cbrauckmuller's avatar

I was actually able to solve this problem by installing Node on my local machine and running gulp from there rather than SSHing into my Homestead environment. Not sure why this works but if anyone else is having the same problem that's what worked for me (also, I'm on a Mac).

IvanBernatovic's avatar

I have the same error. I'm using Windows 8.1 32-bit, no VM's. I have installed nodejs, gulp etc., in fact it had worked on projects before and there were no errors. Here's error:

c:\XAMPP\htdocs\film>npm install --save-dev
npm WARN package.json @ No repository field.
\
> node-sass@2.1.1 install c:\XAMPP\htdocs\film\node_modules\laravel-elixir\node_modules\gulp-sass\node_modules\node-sass
> node scripts/install.js


> node-sass@2.1.1 postinstall c:\XAMPP\htdocs\film\node_modules\laravel-elixir\node_modules\gulp-sass\node_modules\node-sass
> node scripts/build.js

`win32-ia32-node-0.10` exists; testing
Binary is fine; exiting
npm ERR! EEXIST, open 'C:\Users\Ivan\AppData\Roaming\npm-cache\b4512796-adable-stream-1-0-33-package-tgz.lock'
File exists: C:\Users\Ivan\AppData\Roaming\npm-cache\b4512796-adable-stream-1-0-33-package-tgz.lock
Move it away, and try again.

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js"
"install" "--save-dev"
npm ERR! cwd c:\XAMPP\htdocs\film
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR! path C:\Users\Ivan\AppData\Roaming\npm-cache\b4512796-adable-stream-1-0-33-package-tgz.lock
npm ERR! code EEXIST
npm ERR! errno 47
npm ERR! not ok code 0

c:\XAMPP\htdocs\film>gulp

Error: Cannot find module 'laravel-elixir'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (c:\XAMPP\htdocs\film\gulpfile.js:1:76)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)

Can someone help me please?

Edit: typos

jaminday's avatar

I was getting the same lock file error running npm install in Homestead (Windows 8.1 host). From what I can glean there's two issues - one is the long file path problem (try following the guide posted above by nbj), but there also seems to be a race condition causing lock file conflicts which has been addressed in later versions of npm. I had to upgrade npm manually within Homestead to fix the issue.

Steps:

  • SSH into Homestead and check your npm version with npm -v. At time of writing Homestead has v1.4.28 installed by default.
  • Run sudo npm -g install npm@latest to install the latest stable version globally (that is, globally within your Homestead VM). Latest stable version at this time is v2.11.3.
  • You should then be able to npm install --no-bin-links in your Laravel app's home folder.

This worked for me at least, but YMMV. Unfortunately it's a temporary fix as destroying the VM means upgrading npm again, but it's fairly straight forward. Hopefully later versions of the Homestead box will include a more recent version of npm.

NOTE: I haven't fully tested this for any compatibility issues. If you do run into any issues you can always downgrade to Homestead's default with npm -g install npm@1.4 or homestead destroy then homestead up to start fresh.

3 likes
christopher's avatar

If tried to install the latest version on homestead but with no effect

npm -v
1.4.28
☁  ~  sudo npm -g install npm@latest     
npm WARN package.json async@1.4.2 No README data
/home/vagrant/npm/bin/npm -> /home/vagrant/npm/lib/node_modules/npm/bin/npm-cli.js
npm WARN package.json string_decoder@0.10.31 string_decoder is also the name of a node core module.
npm WARN package.json wcwidth@1.0.0 No repository field.
npm@3.3.8 /home/vagrant/npm/lib/node_modules/npm
☁  ~  npm -v
1.4.28

what else could i do?

kieranjfahy's avatar

I had the same problem under windows, I just updated to the latest version of Node.js and it ran perfectly, also has a fancy installer!

michaelpanco's avatar

I solved this problem. There's something issue about shared folder between your VM and Host Operating System

The way i solved this as follow

  1. Inside your virtual machine create a folder name node_modules and copy your package.json in your project directory.

so in your home directory contains

/node_modules

package.json

  1. In your home directory run sudo npm install

  2. in your project directory create node_modules directory and go again to your home directory and run

sudo mount --bind node_modules/ /your_project_path/node_modules/

  • change your_project_path to the location of your project

and that's it! you can run gulp command in your project directory :)

willvincent's avatar

npm should really never be run as sudo.. if you find you're having to run it as sudo you've hosed your permissions, plain and simple.

Amidamaru's avatar

Hi @michaelpanco

I just want to ask. When you say "Inside your virtual machine create a folder name node_modules" , is this root directory of all laravel projects?

Please or to participate in this conversation.