node-sqlite3 icon indicating copy to clipboard operation
node-sqlite3 copied to clipboard

"ENOENT: no such file or directory, rename ..." when running npm install

Open kevinmannn opened this issue 9 years ago • 41 comments

After running npm install --save-dev sqlite3, each subsequent time I try to run npm install I get an error relating to "ENOENT: no such file or directory, rename ...".

The first subsequent run resulted in the following: npm ERR! path /Users/[...]/node_modules/.staging/npmlog-702088a9 npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall rename npm ERR! enoent ENOENT: no such file or directory, rename '/Users/[...]/node_modules/.staging/npmlog-702088a9' -> '/Users/[...]/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog' npm ERR! enoent This is related to npm not being able to find a file.

The next run resulted in this error: npm ERR! path /Users/[...]/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall rename npm ERR! enoent ENOENT: no such file or directory, rename '/Users/[..]/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates' -> '/Users/[...]/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/.delegates.DELETE' npm ERR! enoent This is related to npm not being able to find a file.

Environment: MacOS 10.12.6 NPM 5.3.0 Node v6.11.2 Also occurring on Jenkins on Ubuntu 16.04 LTS.

kevinmannn avatar Aug 16 '17 17:08 kevinmannn

Seems essentially the same issue as #865, just that it seems to hit you on node 6.x while hitting me on 8.x.

bkimminich avatar Aug 16 '17 21:08 bkimminich

the current way I'm working around this is to do the following for each subsequent npm install needed:

  1. Uninstall sqlite3: npm un sqlite3
  2. Install what I need, along with sqlite3: npm i --save ...<all other packages>... sqlite3

Alternatively:

  1. Write my dependencies and version numbers manually into package.json.
  2. Delete node_modules folder: rm -rf node_modules
  3. Install dependencies from package.json: npm i

mauris avatar Aug 20 '17 14:08 mauris

The simplest workaround is to pin sqlite3 package temporarily to 3.1.8.

louisremi avatar Aug 23 '17 07:08 louisremi

How do you pin it, if it is a dependency of another package.

wayofthefuture avatar Aug 23 '17 13:08 wayofthefuture

Same problem, running node v8.3.0 (npm v5.3.0).

How do you pin it, if it is a dependency of another package.

Good q'n. I'm using db-migrate which has a dependency on sqlite3, so here's what I did:

  1. Uninstall the package(s) that depend on sqlite3 (e.g. for me it was npm un db-migrate)
  2. npm i [email protected]
  3. Reinstall the package(s) that depend on sqlite3 (e.g. for me, npm i db-migrate)

Hope it helps 🍺

XieX avatar Aug 24 '17 20:08 XieX

I had a few packages that used sqlite3. The easiest way to find them all was to run npm ls sqlite3

shawnbissell avatar Aug 29 '17 18:08 shawnbissell

Please fix it. We cannot use it. The module doesn't work on any platform.

makamekm avatar Sep 01 '17 10:09 makamekm

+1

wayofthefuture avatar Sep 04 '17 15:09 wayofthefuture

Owners, this is very critical issue and needs to be fixed urgently.

pleerock avatar Sep 06 '17 13:09 pleerock

Anyone hitting this: another workaround (besides deleting the package-lock.json) is to downgrade to npm 3.10.10 instead of npm 5.x, since this is not specific to your node version, but rather the npm version.

I've been investigating. I can replicate with this package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "sqlite3": "3.1.9"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

And node v8.4.0 and npm 5.3.0. The first time I install things work fine. A package-lock.json is placed in the local directory. If I remove this file and install again, the install still works fine. If I keep the package-lock.json in place and install again, then the install fails. This looks a little bit like https://github.com/npm/npm/issues/17444. When re-running the install and having it fail, it fails differently each time:

first failure (on npm install a second time)

npm ERR! path /Users/dane/projects/sqlite3-compare/3.1.9/node_modules/.staging/npmlog-c3818d0a
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/dane/projects/sqlite3-compare/3.1.9/node_modules/.staging/npmlog-c3818d0a' -> '/Users/dane/projects/sqlite3-compare/3.1.9/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog'
npm ERR! enoent This is related to npm not being able to find a file.

second failure (on npm install a third time):

npm ERR! path /Users/dane/projects/sqlite3-compare/3.1.9/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/dane/projects/sqlite3-compare/3.1.9/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates' -> '/Users/dane/projects/sqlite3-compare/3.1.9/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/.delegates.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.

I'm hopeful that https://github.com/mapbox/node-sqlite3/commit/34e1a409b2f4304d2d916e4b4522af9e52efdafb will fix this problem. I am working on issuing a new release that everyone can test with shortly: v3.1.10. WIll ping back here when it is ready.

springmeyer avatar Sep 07 '17 22:09 springmeyer

This should be fixed now in [email protected]. Which means that npm@5 should be able to re-install the latest release without needing to remove the package-lock.json

I think the thing that fixed is is removing the use of "prepublish": "npm ls" (https://github.com/mapbox/node-sqlite3/commit/34e1a409b2f4304d2d916e4b4522af9e52efdafb). I don't know why this fixed it, but one hunch is that the npm ls would run during the install and that triggers some kind of race condition bug in npm 5.3.0 (perhaps related to https://github.com/npm/npm/issues/17455 or https://github.com/npm/npm/issues/18079?).

I'm going to close this now. If anyone still hits the problem with node-sqlite3 at v3.1.10 please re-open a new issue.

springmeyer avatar Sep 08 '17 15:09 springmeyer

I am still seeing this issue with sqlite3 v3.1.12 on Windows 10 (Node.js v8.5.0):

npm ERR! path D:\dev\projects\welovecoding\website\node_modules\sqlite3\node_modules\node-pre-gyp\node_modules\npmlog\node_modules\are-we-there-yet\node_modules\delegates npm ERR! code ENOENT npm ERR! errno -4058 npm ERR! syscall rename npm ERR! enoent ENOENT: no such file or directory, rename 'D:\dev\projects\welovecoding\website\node_modules\sqlite3\node_modules\node-pre-gyp\node_modules\npmlog\node_modules\are-we-there-yet\node_modules\delegates' -> 'D:\dev\projects\welovecoding\website\node_modules\sqlite3\node_modules\node-pre-gyp\node_modules\npmlog\node_modules\are-we-there-yet\node_modules.delegates.DELETE' 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! C:\Users\bennyn\AppData\Roaming\npm-cache_logs\2017-09-26T17_07_33_589Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 4294963238 npm ERR! @welovecoding/[email protected] preversion: npm install && npm run dist && npm test npm ERR! Exit status 4294963238 npm ERR! npm ERR! Failed at the @welovecoding/[email protected] preversion script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

bennycode avatar Sep 26 '17 17:09 bennycode

I can confirm this issue still exists on Linux (armbian 32bit) and npm 5.4.2 as well as on Windows 7 x86_64 and npm 8 both with sqlite3 version 3.1.12.

theCalcaholic avatar Sep 28 '17 13:09 theCalcaholic

We are still seeing this issue on Mac and Windows. npm cache clean --force doesn’t help. We’re using NPM 5.6.0 (latest at this time).

$ npm install npm ERR! path /code/[projectname]/node_modules/@[companyname]/[privatemodulename]/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall rename npm ERR! enoent ENOENT: no such file or directory, rename '/code/[projectname]/node_modules/@[companyname]/[privatemodulename]/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist' -> '/code/[projectname]/node_modules/@[companyname]/[privatemodulename]/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/.minimist.DELETE' 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! /Users/nate/.npm/_logs/2017-12-13T21_51_26_566Z-debug.log

As a workaround, we are deleting the node_modules directory before running npm install. If you run npm install a second time, then it fails. So you have to delete node_modules again before running each NPM command that might change package.json or package-lock.json.

natesilva avatar Dec 13 '17 22:12 natesilva

To follow-up, we were using two private NPM modules that depend on sqlite3.

So our project had an indirect dependency on sqlite3.

I changed both of those modules to use a different database engine and removed their dependency on sqlite3. That fixed the problem. So, at least in our case, the error was caused by something somewhere in this module.

Our earlier solution was to remove package-lock.json and add package-lock = false to .npmrc, but we want to use package-lock.json now, so we can’t do that any more.

Of course we’d love to continue using sqlite3 but this was the solution that worked today.

natesilva avatar Dec 14 '17 00:12 natesilva

I had a similar problem and finally found that the message "This is related to npm not being able to find a file" was, in my case, a handle on folder "node-modules" opened. I had vscode open, closed it then the problem disappears.

dutoitc avatar Dec 30 '17 09:12 dutoitc

Hi all, just delete package-lock.json file and then install package what you want all will works :-)

anandmahajan267 avatar Jan 21 '18 05:01 anandmahajan267

Hi All, I have done by these following simple steps:

  1. Just rename/delete "node_modules" directory in your working project
  2. Fire "F:\www\nginx\html\Ang5App> npm install" command
  3. Add your package name in package.json file (i.e "jquery": "3.2.1")
  4. Then fire npm update with latest version of packages

shreyas135 avatar Jan 21 '18 05:01 shreyas135

Manjaro 17.1.12 Node v.9.4.0 npm v.5.6.0

I had the same problem, removing package-lock.json fixed it for me. This so called 'feature' (package-lock.json) has been nothing but pain for me, ever since its introduction. I should probably add the file to .gitinogre

thebalkanfella avatar Feb 01 '18 20:02 thebalkanfella

Hi,

I am facing the same issue and not sure how to resolve it can you pleaseadvise.

0 info it worked if it ends with ok 1 verbose cli [ 'C:\Program Files\nodejs\node.exe', 1 verbose cli 'C:\Users\sreedhar\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'start' ] 2 info using [email protected] 3 info using [email protected] 4 verbose stack Error: ENOENT: no such file or directory, open 'C:\Idex\package.json' 5 verbose cwd C:\Idex 6 verbose Windows_NT 6.1.7601 7 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\sreedhar\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "start" 8 verbose node v8.9.4 9 verbose npm v5.6.0 10 error path C:\Idex\package.json 11 error code ENOENT 12 error errno -4058 13 error syscall open 14 error enoent ENOENT: no such file or directory, open 'C:\Idex\package.json' 15 error enoent This is related to npm not being able to find a file. 16 verbose exit [ -4058, true ] Note:- removing package-lock.json not worked for me

ShreedharD avatar Feb 11 '18 15:02 ShreedharD