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] Error when linking package installed with GitHub semver #1542

Closed
justincy opened this issue Jul 20, 2020 · 4 comments
Closed

[BUG] Error when linking package installed with GitHub semver #1542

justincy opened this issue Jul 20, 2020 · 4 comments
Labels
Bug thing that needs fixing Release 6.x work is associated with a specific npm 6 release

Comments

@justincy
Copy link

justincy commented Jul 20, 2020

What / Why

npm i and npm ls error with the message Cannot read property '0' of undefined after using npm link to a local package.

`npm i` log
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/usr/local/Cellar/node@12/12.17.0/bin/node',
1 verbose cli   '/usr/local/opt/node@12/bin/npm',
1 verbose cli   'i'
1 verbose cli ]
2 info using npm@6.14.4
3 info using node@v12.17.0
4 verbose npm-session e77d216a1001a8ca
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall genward-web@1.0.0
7 info lifecycle genward-web@1.0.0~preinstall: genward-web@1.0.0
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 verbose stack TypeError: Cannot read property '0' of undefined
10 verbose stack     at npa (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:34:25)
10 verbose stack     at doesChildVersionMatch (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install/deps.js:61:22)
10 verbose stack     at versionMatch (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install/deps.js:758:12)
10 verbose stack     at Array.filter (<anonymous>)
10 verbose stack     at exports.findRequirement (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install/deps.js:768:23)
10 verbose stack     at findChild (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install/deps.js:122:17)
10 verbose stack     at computeMetadata (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install/deps.js:132:9)
10 verbose stack     at Installer.normalizeCurrentTree (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install.js:414:3)
10 verbose stack     at Array.<anonymous> (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
10 verbose stack     at LOOP (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
10 verbose stack     at /usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/node_modules/slide/lib/chain.js:18:7
10 verbose stack     at /usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install.js:368:5
10 verbose stack     at /usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/node_modules/iferr/iferr.js:3:64
10 verbose stack     at asyncMap (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/node_modules/slide/lib/async-map.js:27:18)
10 verbose stack     at exports.getAllMetadata (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install/deps.js:224:3)
10 verbose stack     at Installer.loadArgMetadata (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install.js:366:3)
11 verbose cwd /Users/justinyork/genward/genward-web
12 verbose Darwin 19.5.0
13 verbose argv "/usr/local/Cellar/node@12/12.17.0/bin/node" "/usr/local/opt/node@12/bin/npm" "i"
14 verbose node v12.17.0
15 verbose npm  v6.14.4
16 error Cannot read property '0' of undefined
17 verbose exit [ 1, true ]
`npm ls` log
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/usr/local/Cellar/node@12/12.17.0/bin/node',
1 verbose cli   '/usr/local/opt/node@12/bin/npm',
1 verbose cli   'ls'
1 verbose cli ]
2 info using npm@6.14.4
3 info using node@v12.17.0
4 verbose stack TypeError: Cannot read property '0' of undefined
4 verbose stack     at npa (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:34:25)
4 verbose stack     at doesChildVersionMatch (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install/deps.js:61:22)
4 verbose stack     at versionMatch (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install/deps.js:758:12)
4 verbose stack     at Array.filter (<anonymous>)
4 verbose stack     at exports.findRequirement (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install/deps.js:768:23)
4 verbose stack     at findChild (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install/deps.js:122:17)
4 verbose stack     at computeMetadata (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install/deps.js:132:9)
4 verbose stack     at /usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/ls.js:43:23
4 verbose stack     at /usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install/read-shrinkwrap.js:48:14
4 verbose stack     at /usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/node_modules/iferr/iferr.js:3:64
4 verbose stack     at /usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/lib/install/read-shrinkwrap.js:33:16
4 verbose stack     at tryCatcher (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
4 verbose stack     at Promise._settlePromiseFromHandler (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:517:31)
4 verbose stack     at Promise._settlePromise (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:574:18)
4 verbose stack     at Promise._settlePromise0 (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:619:10)
4 verbose stack     at Promise._settlePromises (/usr/local/Cellar/node@12/12.17.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:699:18)
5 verbose cwd /Users/justinyork/genward/genward-web
6 verbose Darwin 19.5.0
7 verbose argv "/usr/local/Cellar/node@12/12.17.0/bin/node" "/usr/local/opt/node@12/bin/npm" "ls"
8 verbose node v12.17.0
9 verbose npm  v6.14.4
10 error Cannot read property '0' of undefined
11 verbose exit [ 1, true ]

When

When I run npm i and npm ls after using npm link to a local package. I don't know whether other npm commands work. i and ls work properly when the symlink is deleted.

Where

https://github.com/justincy/npm-link-bug

How

Current Behavior

Error

Steps to Reproduce

  1. Install a package with a GitHub semver range
  2. Link the package installed in step 1
  3. npm i and npm ls will error

Minimal reproducible example repo: https://github.com/justincy/npm-link-bug

Expected Behavior

No error.

Who

  • n/a

References

  • n/a
@justincy
Copy link
Author

I believe the bug is right here:

const sameRepo = npa(child.package._from).fetchSpec === requested.fetchSpec

I think the problem is that there's no _from because the package is locally linked. I have no idea what to do about that.

@justincy justincy changed the title [BUG] Cannot read property '0' of undefined [BUG] Error when linking package installed with GitHub semver Jul 20, 2020
@justincy
Copy link
Author

I added a minimal reproducible example.

@justincy
Copy link
Author

Seems to work correctly in v5 but not v6.

@darcyclarke darcyclarke added Release 6.x work is associated with a specific npm 6 release Bug thing that needs fixing labels Oct 30, 2020
@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 preproducible 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 Release 6.x work is associated with a specific npm 6 release
Projects
None yet
Development

No branches or pull requests

2 participants