npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.45k stars 3.15k forks source link

ENOENT: no such file or directory when doing npm install #3917

Closed mathewp-maxamation closed 2 years ago

mathewp-maxamation commented 3 years ago

Host OS: Mac OS Guest OS: Ubuntu 20.4 Environment: VirtualBox

I am trying to run npm install to install dependencies of a project. But I get the below error:

mathew@kallio-local:~/application/kallio-nodejs-server$ npm install
npm WARN deprecated jade@1.11.0: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated cloudant-follow@0.18.2: This package is no longer maintained.
npm WARN deprecated joi@13.7.0: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated hoek@4.2.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated constantinople@3.0.2: Please update to at least constantinople 3.1.1
npm WARN deprecated transformers@2.1.0: Deprecated, use jstransformer
npm WARN deprecated mkdirp@0.3.5: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated connect@2.7.6: connect 2.x series is deprecated
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: 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 hoek@5.0.4: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated topo@3.0.3: This module has moved and is now available at @hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN deprecated hoek@6.1.3: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/mathew/application/kallio-nodejs-server/node_modules/chalk/node_modules/has-flag/package.json.1830067275
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/mathew/application/kallio-nodejs-server/node_modules/chalk/node_modules/has-flag/package.json.1830067275'
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/mathew/.npm/_logs/2021-10-20T09_43_35_439Z-debug.log

But if try the same directly on my Mac it works. It also works when I try to run the same directly on an Ubuntu server

This error occurs when I run in the VirtualBox Ubuntu

To debug this I tried the below steps, but none of them worked:

  1. Reinstall node
  2. Remove package-lock.json
  3. Remove node_modules directory
darcyclarke commented 2 years ago

Seems like this may be a problem with some of the package's dependencies as there are a number of warnings there during install which allude to out-of-date/deprecated dependencies in your project or the environment being problematic. One of those may be trying to use an install script to do something/build itself & is blowing up based on the environment/os/platform. If you want consistent builds, you should probably try to replicate whatever your production env looks like as closely back to your development environment as possible (ex. using docker containers can help here). The debug log will show more information about what exactly was/is happening.

Apologize for the delayed response. Will close this for now but let me know if you continued to have this issue & we can try to help debug.