Installing dependencies fails when a file: dependency requires @babel/preset-env

cli
help-wanted
priority:medium
triaged

(Alf Eaton) #1

What I Wanted to Do

Run npm install in a project that has a file: dependency, which itself has a dependency on @babel/preset-env.

What Happened Instead

An ENOENT error:

npm ERR! path ***/npm-relative-test/project-b/node_modules/.staging/project-a-4f96b5b4/node_modules/@babel/core
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '***/npm-relative-test/project-b/node_modules/.staging/project-a-4f96b5b4/node_modules/@babel/core' -> '***/npm-relative-test/project-b/node_modules/.staging/@babel/core-a61c6f88'
npm ERR! enoent This is related to npm not being able to find a file.

Reproduction Steps

I’ve created a minimal reproduction in https://github.com/hubgit/npm-relative-test

Details

It’s possible to work around this bug by deleting package-lock.json, which works until the node_modules folder is deleted.

Platform Info

$ npm --versions

{ npm: '6.4.1',
  ares: '1.14.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.33.0',
  node: '10.10.0',
  openssl: '1.1.0i',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.0',
  v8: '6.8.275.30-node.24',
  zlib: '1.2.11' }

$ node -p process.platform

darwin

(Alf Eaton) #2

Possibly related:


(Alexey Subach) #3

I have a similar problem but error is a bit different:

npm ERR! path C:\Users\Alexey\Desktop\temp\b\node_modules\.staging\a-33a95d24\node_modules\@babel\code-frame
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Alexey\Desktop\temp\b\node_modules\.staging\a-33a95d24\node_modules\@babel\code-frame' -> 'C:\Users\Alexey\Desktop\temp\b\node_modules\.staging\@babel\code-frame-af4328c6'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

Package A

{
    "name": "a",
    "version": "1.0.0",
    "dependencies": {
        "babel-eslint": "^9.0.0"
    }
}

Package B

{
    "name": "b",
    "version": "1.0.0",
    "dependencies": {
        "a": "file:../a"
    }
}

File Structure:

----a|
-----|----package.json

----b|
-----|----package.json

Steps:

  1. Run npm install for Project A
  2. Run `npm install for Project B
  3. Remove node_modules dir for Project B
  4. Run `npm install for Project B
  5. Error occurs

(Kat Marchán) #4

This is a duplicate of npm install for package with local dependency fails, as @aeaton pointed out.


(Kat Marchán) #5