Skip to content

[BUG] Under 6.14.5, having a package.json provokes a 404 when a local dependency's dev dependency is a local scoped package #1480

@brady-ds

Description

@brady-ds

What / Why

  • Despite the fact that the package in question is local, npm install reports:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/… - Not found
npm ERR! 404 
npm ERR! 404  '…' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

When

  • When package C depends on a local package B,
  • When package B has a dev dependency on local package A,
  • When A is a scoped package,
  • When C already has a package-lock.json, and
  • When I run npm install in C's directory.

Where

  • npm/cli

How

Current Behavior

  • As mentioned above, npm install in C's directory gives an error about installing A. The full log for the steps to reproduce is included below:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session f846a2601b25eb00
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall [email protected]
7 info lifecycle [email protected]~preinstall: [email protected]
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 timing stage:loadCurrentTree Completed in 4ms
11 silly install loadIdealTree
12 silly install cloneCurrentTreeToIdealTree
13 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
14 silly install loadShrinkwrap
15 http fetch GET 404 https://registry.npmjs.org/@scope%2fa 1010ms
16 http fetch GET 404 https://registry.npmjs.org/@scope%2fa 522ms
17 silly fetchPackageMetaData error for @scope/[email protected] 404 Not Found - GET https://registry.npmjs.org/@scope%2fa - Not found
18 timing stage:rollbackFailedOptional Completed in 1ms
19 timing stage:runTopLevelLifecycles Completed in 1568ms
20 silly saveTree [email protected]
20 silly saveTree └── b@file:../b
21 verbose stack Error: 404 Not Found - GET https://registry.npmjs.org/@scope%2fa - Not found
21 verbose stack     at /usr/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:104:15
21 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:97:5)
22 verbose statusCode 404
23 verbose pkgid @scope/[email protected]
24 verbose cwd /…/c
25 verbose Linux 5.3.0-7648-generic
26 verbose argv "/usr/bin/node" "/usr/bin/npm" "install"
27 verbose node v13.14.0
28 verbose npm  v6.14.5
29 error code E404
30 error 404 Not Found - GET https://registry.npmjs.org/@scope%2fa - Not found
31 error 404
32 error 404 '@scope/[email protected]' is not in the npm registry.
33 error 404 You should bug the author to publish it (or use the name yourself!)
34 error 404 Note that you can also install from a
35 error 404 tarball, folder, http url, or git url.
36 verbose exit [ 1, true ]

Steps to Reproduce

  • In an empty directory, I can reproduce the issue with these commands, where the final npm install is the one that gives the log above:
$ mkdir a b c
$ (cd a; npm init -y --scope scope; npm install)
$ (cd b; npm init -y; npm install --save-dev ../a)
$ (cd c; npm init -y; npm install --save ../b)
# Mimic running `npm install` in a fresh clone, which will have `package.json` but not `node_modules`:
$ (cd c; rm -rf node_modules; npm install)

Expected Behavior

  • The install should succeed, as it does before package.json exists, or as it does when A is not a scoped package:
$ mkdir a b c
$ (cd a; npm init -y; npm install)
$ (cd b; npm init -y; npm install --save-dev ../a)
$ (cd c; npm init -y; npm install --save ../b)
# Mimic running `npm install` in a fresh clone, which will have `package.json` but not `node_modules`:
$ (cd c; rm -rf node_modules; npm install)

Who

  • n/a

References

  • n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingRelease 6.xwork is associated with a specific npm 6 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions