Homestead: NPM Install failing on clean homestead box

Created on 15 Jul 2019  ยท  21Comments  ยท  Source: laravel/homestead

Please note that the Homestead issue tracker is reserved for bug reports and enhancements. We are not always able to debug Vagrant, Provider or Operating System issues, but will do our best to help. Thank you!

Versions

  • Vagrant: 2.2.4
  • Provider: Virtualbox v6..0.8 r130347

Host operating system

Arch Linux

Homestead.yaml

ip: 192.168.10.10
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
    - ~/.ssh/id_rsa
folders:
    -
        map: /home/zack/Environments/foo
        to: /home/vagrant/code
sites:
    -
        map: homestead.test
        to: /home/vagrant/code/public
databases:
    - homestead
features:
    -
        mariadb: false
    -
        ohmyzsh: false
    -
        webdriver: false
name: foo
hostname: foo

Vagrant destroy & up output

Gist

Expected behavior

Installation of laravel mix, etc.

Actual behavior

  1. Run NPM install

I receive the following output:

vagrant@foo:~/code$ npm install
npm ERR! path /home/vagrant/code/node_modules/cliui/node_modules/ansi-regex/package.json.3499778098
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/home/vagrant/code/node_modules/cliui/node_modules/ansi-regex/package.json.3499778098'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2019-07-15T14_34_13_985Z-debug.log

I saw issue #866 and specifically, this comment: https://github.com/laravel/homestead/issues/866#issuecomment-494637547

SO I tried that, and got the following output:

vagrant@foo:~/code$ sudo npm install --global cross-env
/usr/bin/cross-env -> /usr/lib/node_modules/cross-env/dist/bin/cross-env.js
/usr/bin/cross-env-shell -> /usr/lib/node_modules/cross-env/dist/bin/cross-env-shell.js
+ [email protected]
added 10 packages from 8 contributors in 0.662s


   โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
   โ”‚                                                                โ”‚
   โ”‚       New minor version of npm available! 6.9.2 โ†’ 6.10.1       โ”‚
   โ”‚   Changelog: https://github.com/npm/cli/releases/tag/v6.10.1   โ”‚
   โ”‚               Run npm install -g npm to update!                โ”‚
   โ”‚                                                                โ”‚
   โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

I figured i wouldn't update yet and tried to install anyways, and got the following error:

vagrant@foo:~/code$ npm install
npm ERR! path /home/vagrant/code/node_modules/webpack-cli/node_modules/ansi-regex/package.json.1463230163
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/home/vagrant/code/node_modules/webpack-cli/node_modules/ansi-regex/package.json.1463230163'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2019-07-15T14_38_27_528Z-debug.log

So I updated node as the notice said and ran npm install again and it failed still, with the same error

I also tried to run npm update, tried cleaning the npm cache, and installing again, and still get the same error.

Composer update output

Steps to reproduce

  1. npm install

Most helpful comment

Looks like this is related to a long standing Virtualbox issue. You can try what was discussed here: https://github.com/laravel/homestead/issues/922 but the TL;DR is "Use Yarn" or "Run NPM on your host OS"

Sorry we can't be much more help.

All 21 comments

I also tried downloading the latest dev version of the project template from the cabinet server and used that package.json to the same result.

Even stranger, the package seems to change each time i run npm install.

https://gist.github.com/zack6849/b4507a48f6a8e8615e083edbe2675574

Note, I wasn't changing the filesystem or anything in the background between runs.

I'm able to confirm:

vagrant@homestead:~$ cd fresh/
vagrant@homestead:~/fresh$ ll
total 424
drwxr-xr-x  1 vagrant vagrant    832 Jul 16 14:52 ./
drwxr-xr-x 13 vagrant vagrant   4096 Jul 16 14:54 ../
drwxr-xr-x  1 vagrant vagrant    224 Jul 16 14:51 app/
-rw-r--r--  1 vagrant vagrant   1686 Jul 16 14:51 artisan
drwxr-xr-x  1 vagrant vagrant    128 Jul 16 14:51 bootstrap/
-rw-r--r--  1 vagrant vagrant   1550 Jul 16 14:51 composer.json
-rw-r--r--  1 vagrant vagrant 167523 Jul 16 14:51 composer.lock
drwxr-xr-x  1 vagrant vagrant    480 Jul 16 14:51 config/
drwxr-xr-x  1 vagrant vagrant    192 Jul 16 14:51 database/
-rw-r--r--  1 vagrant vagrant    213 Jul 16 14:51 .editorconfig
-rw-r--r--  1 vagrant vagrant    777 Jul 16 14:52 .env
-rw-r--r--  1 vagrant vagrant    726 Jul 16 14:51 .env.example
-rw-r--r--  1 vagrant vagrant    111 Jul 16 14:51 .gitattributes
-rw-r--r--  1 vagrant vagrant    163 Jul 16 14:51 .gitignore
-rw-r--r--  1 vagrant vagrant   1126 Jul 16 14:51 package.json
-rw-r--r--  1 vagrant vagrant   1156 Jul 16 14:51 phpunit.xml
drwxr-xr-x  1 vagrant vagrant    256 Jul 16 14:51 public/
drwxr-xr-x  1 vagrant vagrant    192 Jul 16 14:51 resources/
drwxr-xr-x  1 vagrant vagrant    192 Jul 16 14:51 routes/
-rw-r--r--  1 vagrant vagrant    563 Jul 16 14:51 server.php
drwxr-xr-x  1 vagrant vagrant    160 Jul 16 14:51 storage/
-rw-r--r--  1 vagrant vagrant    174 Jul 16 14:51 .styleci.yml
drwxr-xr-x  1 vagrant vagrant    192 Jul 16 14:51 tests/
drwxr-xr-x  1 vagrant vagrant   1312 Jul 16 14:52 vendor/
-rw-r--r--  1 vagrant vagrant    538 Jul 16 14:51 webpack.mix.js
-rw-r--r--  1 vagrant vagrant 209965 Jul 16 14:51 yarn.lock
vagrant@homestead:~/fresh$ npm install
npm ERR! path /home/vagrant/fresh/node_modules/yargs/node_modules/yargs-parser/package.json.2290810957
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/home/vagrant/fresh/node_modules/yargs/node_modules/yargs-parser/package.json.2290810957'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2019-07-16T14_55_53_771Z-debug.log
vagrant@homestead:~/fresh$

Doesn't look like it's happening on MacOS natively, will look into it.

Looks like this is related to a long standing Virtualbox issue. You can try what was discussed here: https://github.com/laravel/homestead/issues/922 but the TL;DR is "Use Yarn" or "Run NPM on your host OS"

Sorry we can't be much more help.

fwiw I just verified Yarn is still good to go:

` vagrant@homestead:~/fresh$ yarn install yarn install v1.16.0 warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json. [1/4] Resolving packages... [2/4] Fetching packages... info [email protected]: The platform "linux" is incompatible with this module. info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation. info [email protected]: The platform "linux" is incompatible with this module. info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... warning " > [email protected]" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0". [4/4] Building fresh packages... warning Your current version of Yarn is out of date. The latest version is "1.17.3", while you're on "1.16.0". info To upgrade, run the following command: $ curl --compressed -o- -L https://yarnpkg.com/install.sh | bash Done in 28.55s. vagrant@homestead:~/fresh$

@svpernova09 Hey, thanks for the heads up re: using yarn

Is it recommended to do that?

Also, I appreciate your troubleshooting, but if you don't mind explaining, what leads you to believe this and #922 are related, the error messages seem pretty different.

"Run NPM on your host OS"

FYI, unlike with composer, npm packages can compile native code (libsass is the most common), so if you do that you'll be trying to run macOS binaries on linux which will error out.

Then the answer should be โ€œcopy the directory out of a shared folder and run the command then copy back to the shareโ€ which sounds pretty crappy. Can we just stop supporting virtual box? (Iโ€™m kidding)

--

"Run NPM on your host OS"
FYI, unlike with composer, npm packages can compile native code (libsass is the most common), so if you do that you'll be trying to run macOS binaries on linux which will error out.
โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Last I was on Windows, I found using rsync + the vagrant rsync-back plugin was the "best" solution. Not 100% because of how symlinks aren't possible to replicate on NTFS, but close enough to get me through the week.

Is virtualbox not the de-facto standard for homestead? I feel silly, but my understanding was that homestead was supposed to be a drop in dev environment for basically any os, and valet was the OS X specific one, but it seems to me like homestead, while it mostly works, is still mostly aimed towards mac users?

Virtualbox is the most common provider for vagrant because itโ€™s free and relatively stable (all things considered)

--

Is virtualbox not the de-facto standard for homestead? I feel silly, but my understanding was that homestead was supposed to be a drop in dev environment for basically any os, and valet was the OS X specific one, but it seems to me like homestead, while it mostly works, is still mostly aimed towards mac users?
โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

for me on windows 10, I faced the same issue and solved it by adding:

type: "smb"
mount_options: ["mfsymlinks,dir_mode=0755,file_mode=0775"]

It seems to be an npm & virtualbox issue.

I found an alternative way, install npm on your computer then install nuxt .js inside your local homestead sync folder and that's it.

I have this problem if I execute the npm command in a synced folder with the host. If I execute the command in a not synced folder it works fine, so I think it is a sync problem.

Test:

$ mkdir test
$ cd test
$ npm init -y
$ npm install grunt --save-dev

Environment:

  • Windows 10
  • VM Virtualbox 6.0.8 r130520
  • Vagrant 2.2.5
  • Homestead Box 8.0.0

I have solved this problem mapping the folder as "nfs" type:

folders:
    - map: C:\Users\myuser\development
      to: /home/vagrant/code
      type: "nfs"

Environment:

  • Windows 10
  • VM Virtualbox 6.0.8 r130520
  • Vagrant 2.2.5
  • Homestead Box 8.0.0

Upgrade your base box to 8.0.1 and you wonโ€™t have to use NFS

--

  • Joe Ferguson
    JoeFerguson.me
    osmihelp.org
    On Aug 21, 2019, 04:49 -0400, Jesรบs Amieiro Becerra notifications@github.com, wrote:

I have solved this problem mapping the folder as "nfs" type:
folders:

  • map: C:\Users\myuser\development
    to: /home/vagrant/code
    type: "nfs"
    Environment:

โ€ข Windows 10
โ€ข VM Virtualbox 6.0.8 r130520
โ€ข Vagrant 2.2.5
โ€ข Homestead Box 8.0.0

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

I understand the issue that affects Windows hosts. However, I also get this same error and behavior on MacOS. Does anyone have any idea what is causing this on MacOS/Linux hosts?

@liamoreilly I ran into this issue as well on my mac. I use Homestead 10.8.0 and recently upgraded Vagrant, Virtual Box and Homestead (2 weeks ago). Since then, I ran into the issue twice when trying to do a npm install.

For the first project I just used yarn. For the other project I did the install on the home machine, i.e., on my mac itself.

I ran into same issue on my Mac, install clean fresh homestead, and vagrant. npm install is failed, success with yarn.

Looks like this is related to a long standing Virtualbox issue. You can try what was discussed here: #922 but the TL;DR is "Use Yarn" or "Run NPM on your host OS"

Sorry we can't be much more help.

Worked for me, Thanks

Here is a working solution.

Host: MacOs Catalina

VM: Homestead vagrant virtualbox
NPM: 6.14.10
NODE: 10.16.2

First install nvm

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

quit terminal and reopen a new terminal

npm install -g [email protected]

nvm install 10.16.2

(in your project folder)
rm -R node_modules/
rm package-lock.json
npm cache verify

yarn install

et voila !
you now can run your so desired npm run dev ! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pqt picture pqt  ยท  3Comments

it-can picture it-can  ยท  3Comments

mtpultz picture mtpultz  ยท  4Comments

teleclimber picture teleclimber  ยท  3Comments

steveheinsch picture steveheinsch  ยท  3Comments