TryGhost / node-sqlite3

SQLite3 bindings for Node.js
BSD 3-Clause "New" or "Revised" License
6.22k stars 815 forks source link

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

Closed kevinmannn closed 7 years ago

kevinmannn commented 7 years ago

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.

bkimminich commented 7 years ago

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

mauris commented 7 years ago

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

louisremi commented 7 years ago

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

wayofthefuture commented 7 years ago

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

XieX commented 7 years ago

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 sqlite3@3.1.8
  3. Reinstall the package(s) that depend on sqlite3 (e.g. for me, npm i db-migrate)

Hope it helps 🍺

shawnbissell commented 7 years ago

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

makamekm commented 7 years ago

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

wayofthefuture commented 7 years ago

+1

pleerock commented 7 years ago

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

springmeyer commented 7 years ago

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 commented 7 years ago

This should be fixed now in sqlite@3.1.10. 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.

bennycode commented 7 years ago

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/website@1.0.18 preversion: npm install && npm run dist && npm test npm ERR! Exit status 4294963238 npm ERR! npm ERR! Failed at the @welovecoding/website@1.0.18 preversion script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

theCalcaholic commented 7 years ago

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.

natesilva commented 6 years ago

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 commented 6 years ago

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.

dutoitc commented 6 years ago

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.

anandmahajan267 commented 6 years ago

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

shreyas135 commented 6 years ago

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
thebalkanfella commented 6 years ago

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

ShreedharD commented 6 years ago

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 npm@5.6.0 3 info using node@v8.9.4 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

its-poole commented 6 years ago

If you are running circle CI and managed to get build to succeed using one of the above methods, and it still fails on circle CI, then try doing a rebuild w/o cache so it purges old dependencies (likely still hanging on to version of sqlite3 in cache since it caches node_modules.

redii commented 6 years ago

Deleting package-lock.json or node_modules/ didnt worked for me. After running: npm install -g npm ... it started working for me again.

fernando-ontiveros-mojix-com commented 6 years ago

package-lock.json worked for me then rm -rf node_modules and finally npm install

seems there are some references in package-lock.json that npm try to satisfy, and since they are not valid anymore it stop.

ghost commented 6 years ago

Seeing this issue on npm 5.8.0

npm ERR! path /mnt/Temp/svc-project/node_modules/.isobject.DELETE/node_modules/isarray
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/mnt/Temp/svc-project/node_modules/.isobject.DELETE/node_modules/isarray' -> '/mnt/Temp/svc-project/node_modules/isobject/node_modules/isarray'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 
dy10 commented 6 years ago

saw this with npm 5.6.0; on upgrading to npm 6.0.0 it went away

nikhilmundhra commented 6 years ago

Error on restoring packages from package.json in quickstart-master downloaded from https://github.com/angular/quickstart. I am using it to run angular 2 in Visual Studio 2015. I have followed https://angular.io/guide/visual-studio-2015 for installation of quickstart files in visual studio 2015.

Error on restoring packages from package.json :-

npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue npm WARN deprecated uws@9.14.0: stop using this version npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\supports-color-91851346\package.json' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\has-ansi-3495030d\package.json' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\strip-ansi-fbce9964\package.json' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\supports-color-91851346\index.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\has-ansi-3495030d\index.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\strip-ansi-fbce9964\index.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\supports-color-91851346\license' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\has-ansi-3495030d\license' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\strip-ansi-fbce9964\license' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\supports-color-91851346\readme.md' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\has-ansi-3495030d\readme.md' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\strip-ansi-fbce9964\readme.md' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\ua-parser-js-568c885b\src\ua-parser.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\readable-stream-dab5ec6f\lib_stream_duplex.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\tmp-79cf1820\lib\tmp.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\tough-cookie-4dbedf2b\lib\cookie.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\readable-stream-dab5ec6f\lib_stream_passthrough.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\readable-stream-dab5ec6f\lib_stream_readable.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\@angular\http-cc877983\src\http_module.d.ts' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\@angular\platform-browser-c62ac93c\@angular\platform-browser\animations.es5.js' npm WARN tar ENOENT: no such file or directory, open 'C:\Users\nikhil.mundhra\Documents\Visual Studio 2015\Projects\InvMgmtApp\InvMgmtApp\node_modules.staging\when-81a1c626\unfold\list.js' npm ERR! code E403 npm ERR! 403 Forbidden: selenium-webdriver@2.53.3 npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\nikhil.mundhra\AppData\Roaming\npm-cache_logs\2018-06-18T12_53_33_022Z-debug.log

====npm command completed with exit code 1====

What should I do?

springmeyer commented 6 years ago

anyone still seeing this, please upgrade npm: https://github.com/npm/npm/issues/17444#issuecomment-393761515

garthk commented 6 years ago

@springmeyer, I'm getting this on 6.3.0 right now.

springmeyer commented 6 years ago

@garthk are you also running the latest node-sqlite3 release? (https://github.com/mapbox/node-sqlite3/releases)

limistah commented 5 years ago

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.

This solved it for me.

nateshmbhat commented 5 years ago

Deleting the package-lock.json and a npm install fixed it for me.

americk0 commented 5 years ago

I had the same problem and was able to resolve this by running npm uninstall <package> for the package it was saying it couldn't find and then re-running npm install again

shouvikbhuiyan1990 commented 5 years ago

deletedpackage-lock.jsonand ran npm install again. Worked like a charm for me.

sunnykgupta commented 5 years ago

Discussed at length here: https://npm.community/t/npm-install-for-package-with-local-dependency-fails/754/7

In short - solved by upgrading npm - npm i -g npm@next (the fix is currently in v6.9.0 which is not released yet).

After the upgrade, remove node_modules once and try npm i any number of times. Should work.

csprocket777 commented 5 years ago

experienced this today, verified that updating to npm@6.9.0 worked to solve it.

ethlyseria commented 5 years ago

Tried almost everything, even I'm using the npm@6.9.0, still facing the same error

guyalo commented 5 years ago

sudo npm install -g npm worked for me

I521422 commented 4 years ago

sudo npm install -g npm worked for me, just update everything.

YinianFan commented 4 years ago

delete package-lock.json and then install again. That works for me

SwiftWinds commented 3 years ago

For me, it was because it was in a Dropbox folder. Moving it out of the folder fixed it.

fdmxfarhan commented 3 years ago

us npm ci to clean and install all packages. and then install the package you want. it works for me this way