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

[BUG] Npm install with local dependency and package-lock.json throws error #1414

Closed
McSiMusic opened this issue Jun 10, 2020 · 7 comments
Closed
Labels
Bug thing that needs fixing

Comments

@McSiMusic
Copy link

What / Why

I have a three npm project:
npm sample.zip
After running a script.ps1 I am getting error:

ENOENT
npm ERR! syscall rename
npm ERR! path D:\npm sample\c\node_modules\.staging\underscore-df67550f
npm ERR! dest D:\npm sample\a\node_modules\underscore
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, rename 'D:\npm sample\c\node_modules\.staging\underscore-df67550f' -> 'D:\npm sample\a\node_modules\underscore'
npm ERR! enoent This is related to npm not being able to find a file.

script just running npm install in sequence.

When

Whenever i running script in arhchive

Where

local npm dependency

How

There are a three projects with local dependency:
b project has a dependency on a project
c project has a dependency on a and b project.
if running npm first time - ok
but if removing all node_modules folders, and run npm install in sequence - c npm install crashes

Steps to Reproduce

Download and Extract archive
Run script.ps1

Expected Behavior

All installed without errors

Node version is v12.16.2

@jpoissant
Copy link

This looks like the same issue (not fixed) found in this old npm community post.

I have the same issue. If you delete the package-lock.json file it works, but it's not the expected behavior (to delete the file each time)

@adrianschmidt
Copy link

adrianschmidt commented Jul 9, 2020

This looks like the same issue (not fixed) found in this old npm community post.

The accepted solution links to PR #86, so I wonder if this might be a regression of a previously fixed bug.

I have the same issue. If you delete the package-lock.json file it works, but it's not the expected behavior (to delete the file each time)

You can also fix the issue by removing the previously installed version of the package you are trying to install a local copy of:

$ npm install ../my-package
#  ERROR blah blah

$ rm -rf node_modules/my-package

$ npm install ../my-package
#  SUCCESS!

This only fixes the problem temporarily though. You'll have to jump through the same hoops next time you want to install the local version after having had the published version installed in-between.

@darcyclarke darcyclarke added the Bug thing that needs fixing label Oct 30, 2020
@fkotsian
Copy link

fkotsian commented Apr 19, 2021

Thirded, this appears to have been fixed in #86, then again in #216

A relevant pull with test cases appears to have been closed in #254

Any way to get this fixed before NPMv7? Currently this is still broken on my 6.14.13:

# local pkg-a requires local pkg-b
fkotsian ~/workspace/sky (design/allow-byzantine-babel) $ npm ci
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/fkotsian/workspace/sky/node_modules/pkg-a/node_modules/pkg-b/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/fkotsian/workspace/sky/node_modules/pkg-a/node_modules/pkg-b/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

# pkg-b/package.json not found

The interesting thing is pkg-b/package.json exists in the installed modules:

fkotsian ~/workspace/sky (design/allow-byzantine-babel) $ ls node_modules/pkg-a/node_modules/pkg-b
.env                 config-overrides.js  package-lock.json    scripts/
.eslintrc.js         jsconfig.json        ***package.json***         src/
__mocks__/           node_modules/        public/

EDIT: issue also referenced here, with some more digging: #529

@ljharb
Copy link
Contributor

ljharb commented Apr 19, 2021

@fkotsian npm 7 is out, and up to v7.10.0. can you try that and see if it fixes your issue?

@fkotsian
Copy link

@fkotsian npm 7 is out, and up to v7.10.0. can you try that and see if it fixes your issue?

Thanks for the heads up! Let me give that a shot

@fkotsian
Copy link

@ljharb Indeed it does!

fkotsian ~/workspace/sky (design/allow-byzantine-babel) $ rm -rf node_modules/
fkotsian ~/workspace/sky (design/allow-byzantine-babel) $ npm ci

added 3790 packages, and audited 6431 packages in 1m

62 vulnerabilities (31 low, 8 moderate, 23 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
fkotsian ~/workspace/narmi/banking/sky (design/allow-byzantine-babel) $ npm --version
7.10.0

Thanks for the word!

@darcyclarke
Copy link
Contributor

npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.

If your bug is reproducible on v7, please re-file this issue using our new issue template.

If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo

Closing: This is an automated message.

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

No branches or pull requests

6 participants