Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm can't install or update #2529

Open
columbian-chris opened this issue Sep 30, 2021 · 21 comments
Open

npm can't install or update #2529

columbian-chris opened this issue Sep 30, 2021 · 21 comments
Labels

Comments

@columbian-chris
Copy link

I have tried everything I could find and nothing will fix my problem. I cannot for the life of me get this npm install or update error to resolve.

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /srv/www/columbian/public_html/wp-content/themes/columbian2/node_modules/ansi-align/node_modules/ansi-regex/package.json.4193727334
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/srv/www/columbian/public_html/wp-content/themes/columbian2/node_modules/ansi-align/node_modules/ansi-regex/package.json.4193727334'
npm ERR! enoent This is related to npm not being able to find a file.

It is not specific to this package. Trying different things throws the same error and gets caught up on a different package after I try different things.

I have tried:

  • clearing the cache (npm cache clean --force)
  • deleting the node_modules directory and doing a fresh npm install
  • tried using Node 12 and 10
  • tried running as root user
  • tried chmod-ing 777 to everything in the node_modules dir
  • deleting the package-lock.json file and trying again
  • manually deleting any hidden/temporary folders in node_modules created during attemtps
  • using some custom npm commands some people suggested on SO:
    • npm rebuild
    • npm install --cache /tmp/empty-cache
    • npm cache verify
    • npm prune
    • npm update --no-bin-links

...nothing seems to work. Any suggestions?

Using:
MacOS 11.5.2
VVV 3.7.2
Vagrant 2.2.18
virtualbox 6.1.26

@welcome
Copy link

welcome bot commented Sep 30, 2021

Thanks for opening your first issue here! Be sure to follow the issue template and include your OS/Vagrant/VVV versions! Don't forget you can get support in the VVV slack at https://varyingvagrantvagrants.org/docs/en-US/slack/

VVV
Join the VVV Slack Workspace

@tomjn
Copy link
Member

tomjn commented Sep 30, 2021

It's extremely unlikely that there is a VVV oriented solution to this. The only things I can suggest are all Windows related issues regarding symlink support, which is not an issue on MacOS hosts.

@tomjn
Copy link
Member

tomjn commented Sep 30, 2021

If I had to grasp at straws:

  • check that your guest and your host haven't ran out of disk space
  • try this in a folder that is not mounted e.g. /tmp
  • does it work if you run it on the host? VVV may serve the files and database but nothing prevents you using npm/node on MacOS
  • booo 6.1.26 booooo, terrible version, boooo, burn with the fire of a thousand suns, boooo, I have lots of anecdotes about this version of VirtualBox, all of them are universally bad for different ambiguous reasons. All anecdotes about downgrading are about how they fixed mysterious issues.
  • also, VVV is not npm, I can't do much to help if I can't reproduce the issue

@columbian-chris
Copy link
Author

I spun up a fresh default VVV installation without any customization or configuration and provisioned the vagrant box and ssh'ed into it and I experienced the same issue in it. Also because it's a completely fresh install, that implies to me that there isn't a disk space issue happening.

I ran npm install in the /tmp dir and it successfully ran, so what can we learn from that ???

I was able to successfully use npm without error on the host (MacOS).

I tried to downgrade VirtualBox to 6.0 and the installation would just fail, but duly noted.

@tomjn
Copy link
Member

tomjn commented Oct 1, 2021

@columbian-chris do you have instructions to reproduce? Where is gulp-boilerplate coming from?

I tried to downgrade VirtualBox to 6.0 and the installation would just fail, but duly noted.

kernel extensions need to be removed, you have to run the Virtualbox uninstaller, you can' just install an older version over the top

@tomjn
Copy link
Member

tomjn commented Oct 1, 2021

I'm sure at some point the command you were running that was failing was in this issue? You're describing the results of what you're trying to do but you've never actually shared what it is that you did, please share explicit instructions with commands and links so that I can reproduce step for step what you did locally at my end

@tomjn
Copy link
Member

tomjn commented Oct 1, 2021

also stable branchordevelop` branch?

@columbian-chris
Copy link
Author

I'm sure at some point the command you were running that was failing was in this issue? You're describing the results of what you're trying to do but you've never actually shared what it is that you did, please share explicit instructions with commands and links so that I can reproduce step for step what you did locally at my end

The easiest reproduction could possibly be to run an npm command with the list of packages I was trying to install so I'll give you that:

npm install bootstrap bootstrap-icons gulp gulp-autoprefixer gulp-cli gulp-concat gulp-csso gulp-imagemin gulp-livereload gulp-plumber gulp-sass gulp-sourcemaps gulp-uglify intersection-observer js-cookie popper.js slim-select tablesorter tiny-date-picker

@columbian-chris
Copy link
Author

also stable branchordevelop` branch?

Sorry, of which software? I didn't use the development branch or release of anything I was using. It should all be stable or LTS.

@columbian-chris
Copy link
Author

kernel extensions need to be removed, you have to run the Virtualbox uninstaller, you can' just install an older version over the top

I tried to use the uninstall tool, but MacOS prevented me from doing so and said “VirtualBox_Uninstall.tool” cannot be opened because it is from an unidentified developer.

@tomjn
Copy link
Member

tomjn commented Oct 1, 2021

Sorry, of which software? I didn't use the development branch or release of anything I was using. It should all be stable or LTS.

@columbian-chris of VVV, we don't have an LTS release

I tried to use the uninstall tool, but MacOS prevented me from doing so and said “VirtualBox_Uninstall.tool” cannot be opened because it is from an unidentified developer.

Go to the security options pane of system preferences and press allow then try again.

@tomjn
Copy link
Member

tomjn commented Oct 1, 2021

Also that's a lot of packages to install at the same time!

Here's my splash screen for reference:

❯ vagrant up --provision
__ __ __ __
\ V\ V\ V / v3.7.2 Path:"/Users/tarendai/dev/vvv"
 \_/\_/\_/  git::develop(4dcce2f)

Platform: darwin19 shell:/bin/bash vagrant-goodhosts vagrant-vbguest shared_db_folder_disabled
Vagrant: v2.2.18, virtualbox: v6.1.24

Docs:       https://varyingvagrantvagrants.org/
Contribute: https://github.com/varying-vagrant-vagrants/vvv
Dashboard:  http://vvv.test

I tried to run the command and it succeeded when ran in an empty folder:

vagrant@vvv:/srv/www/wordpress-one/public_html/wp-content/themes$ mkdir npmtest
vagrant@vvv:/srv/www/wordpress-one/public_html/wp-content/themes$ cd npmtest/
vagrant@vvv:/srv/www/wordpress-one/public_html/wp-content/themes/npmtest$ npm install bootstrap bootstrap-icons gulp gulp-autoprefixer gulp-cli gulp-concat gulp-csso gulp-imagemin gulp-livereload gulp-plumber gulp-sass gulp-sourcemaps gulp-uglify intersection-observer js-cookie popper.js slim-select tablesorter tiny-date-picker
npm WARN deprecated [email protected]: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm WARN deprecated [email protected]: cross-spawn no longer requires a build toolchain, use it instead

> [email protected] postinstall /srv/www/wordpress-one/public_html/wp-content/themes/npmtest/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> [email protected] postinstall /srv/www/wordpress-one/public_html/wp-content/themes/npmtest/node_modules/gifsicle
> node lib/install.js

  ✔ gifsicle pre-build test passed successfully

> [email protected] postinstall /srv/www/wordpress-one/public_html/wp-content/themes/npmtest/node_modules/mozjpeg
> node lib/install.js

  ✔ mozjpeg pre-build test passed successfully

> [email protected] postinstall /srv/www/wordpress-one/public_html/wp-content/themes/npmtest/node_modules/optipng-bin
> node lib/install.js

  ✔ optipng pre-build test passed successfully
npm WARN saveError ENOENT: no such file or directory, open '/srv/www/wordpress-one/public_html/wp-content/themes/npmtest/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN enoent ENOENT: no such file or directory, open '/srv/www/wordpress-one/public_html/wp-content/themes/npmtest/package.json'
npm WARN [email protected] requires a peer of @popperjs/core@^2.10.1 but none is installed. You must install peer dependencies yourself.
npm WARN npmtest No description
npm WARN npmtest No repository field.
npm WARN npmtest No README data
npm WARN npmtest No license field.

+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
added 901 packages from 382 contributors and audited 903 packages in 80.225s

62 packages are looking for funding
  run `npm fund` for details

found 8 vulnerabilities (2 low, 2 moderate, 4 high)
  run `npm audit fix` to fix them, or `npm audit` for details


   ╭───────────────────────────────────────────────────────────────╮
   │                                                               │
   │      New major version of npm available! 6.14.10 → 7.5.2      │
   │   Changelog: https://github.com/npm/cli/releases/tag/v7.5.2   │
   │               Run npm install -g npm to update!               │
   │                                                               │
   ╰───────────────────────────────────────────────────────────────╯

vagrant@vvv:/srv/www/wordpress-one/public_html/wp-content/themes/npmtest$ 

@tomjn
Copy link
Member

tomjn commented Oct 1, 2021

Node v14.18.0 and npm 6.14.15

@columbian-chris
Copy link
Author

Go to the security options pane of system preferences and press allow then try again.

I did so and used the uninstall tool and tried reinstalling and it still fails for some reason. Maybe it's not compatible with my version of MacOS.

Screen Shot 2021-10-01 at 1 31 53 PM

@columbian-chris
Copy link
Author

If it's working fine on your end, I'm not sure what to think at this point. I feel like I'm going to have to just find a workaround.

@tomjn
Copy link
Member

tomjn commented Oct 2, 2021 via email

@columbian-chris
Copy link
Author

I will have to try downgrading virtualbox again when I get a chance with deeper instructions to ensure I'm completely clearing out everything.

Today, I can get a fresh npm install to run if I delete all the node modules and the package-lock.json file. I'm noticing that it always is leaving behind a ton of hidden folders in the node_modules dir and then throwing errors about files within them (like ENOTEMPTY: directory not empty) if I don't delete them before running another npm command.

Example bunch of hidden files left behind:

.acorn-t9RSi9qX
.atob-ddgO3NEi
.autoprefixer-kzS2sdhU
.bin
.depcheck-ej1rzFMr
.esprima-9YzcM93c
.fast-xml-parser-UwCb0HqE
.gifsicle-QTps6ljg
.gulp-cli-6dg0wP4t
.gulp-XB0xevT6
.he-0ImkaW7P
.js-yaml-4FQUlnc2
.jsesc-7WKh6D5K
.mkdirp-jzRFfqsy
.mozjpeg-RYpu1dTP
.nanoid-3feEBV0E
.npm-check-WDGskL0C
.optipng-bin-IZOtOHnj
.package-lock.json
.rc-b7AY4sMo
.sass-7n1Z7SWK
.seek-bzip-LNXBn8lT
.semver-KxQw6ytQ
.svgo-J2Blsq01
.uglify-js-AABh06zL
.uuid-hbdCwbDs
.which-Lifs4sPv

When npm is finished installing a package, I expect it's supposed to remove these. To confirm that, it is working normally when I try inside the /tmp/ directory. I haven't spotted any permissions issues so I'm not sure why npm isn't successfully removing these.

@tomjn
Copy link
Member

tomjn commented Oct 6, 2021

can you try installing the nvm utility and use it to install Node then update npm? Something like nvm use lts && npm update -g npm? ( untested commands )

As an aside, have you tried running it on the host instead? It's great having node inside the VM particularly for running node projects, but watchers always run best on the host. VMs introduce micro-caches that sometimes miss file update events, and other tech such as docker can trigger heavy CPU trying to make the opposite tradeoff. It also makes IDE/editor integration much easier

@alxbarron
Copy link

alxbarron commented Feb 17, 2022

I was having the same issue, and I was refusing to try this so I was already resigned to run the npm commands through the host's terminal.

I decide to downgrade the npm 8.3.1 version on my local to the default version for node v14.18.1 which is npm 6.14.15, so just for curiosity I tried for the last time after the downgrade to run the installation script through the vvv-vm and this time it worked just fine. So it may worth the shot to validate your node/npm versions betwen your host and the vvv-vm, note that in my case they don't exactly match but the mayor versions do matches.

Before

vvv-vm
- node v14.19.0 w/ npm 6.14.16
host
- node v14.18.1 w/ npm 8.3.1

After

vvv-vm
- node v14.19.0 w/ npm 6.14.16
host
- node v14.18.1 w/ npm 6.14.15

cc: @columbian-chris @tomjn

@tomjn
Copy link
Member

tomjn commented Feb 17, 2022

ENOENT is a very generic error code, I've encountered this on the host when no VM or VVV is involved because VSCode was running commands. It can even happen due to file ownership or because Explorer was generating a thumbnail preview.

It can happen even if VVV is operating perfectly with no bugs, or if there is no VVV at all. It's a general npm issue, not a VVV issue.

The most effective solution is usually npm -rf node_modules && npm install.

@alxbarron you may find the nvm PR currently in progress interesting, I'd be curious for any feedback you have for it, or just testing

@tomjn
Copy link
Member

tomjn commented Feb 17, 2022

I'd also suggest minimum versions in package.json:

  "engines": {
    "node": ">=14.17.0",
    "npm": ">=7.18.0"
  },

It's not a good idea to mix major versions of npm, if only for lock file stability in version control

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants