npm / npm/cli

[BUG] npm link <package>: Cannot read properties of null (reading 'matches')

Open
#4,367 30 comments 33 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Priority 2 Release 8.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
This issue exists in the latest npm version
  • I am using the latest npm
Current Behavior

Running npm link react in my library gives me the following output:

$ npm link react
npm ERR! Cannot read properties of null (reading 'matches')

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ploppz/.npm/_logs/2022-02-03T11_48_09_016Z-debug-0.log

And no link happens. The log:

Expected Behavior

No error, and symbolic link created in node_modules with name react

Steps To Reproduce

I have npm installed from official Arch repo.

I have an app called ui. I went into its node_modules/react after npm i and ran sudo npm link. As such, a symbolic link was created called /usr/lib/node_modules/react which points to this directory:

$ ls -l /usr/lib/node_modules
lrwxrwxrwx  1 root   root     49 Jan 31 14:30  react -> ../../../home/ploppz/ui/node_modules/react/
(rest redacted)

I have a shared library called components in which I need to link to this react installation, so I run npm link react in there and get the above problem.
npm link react worked fine yesterday with the same setup, and it still work perfectly fine in a second application I'm developing with the same components library... It's just in the components library itself it won't work.

Note that also the components library itself is linked with sudo npm link

Environment
  • npm: 8.3.2
  • Node.js: 17.3.0
  • OS Name: Arch Linux
  • System Model Name: ?
  • npm config:
; node bin location = /usr/bin/node
; cwd = /home/ploppz/components
; HOME = /home/ploppz
; Run `npm config ls -l` to show all defaults.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce npm link react from the components library using the stated npm 8.3.2, Node.js 17.3.0, and Arch Linux setup, then inspect the debug log at /home/ploppz/.npm/_logs/2022-02-03T11_48_09_016Z-debug-0.log. Done means the command completes without the null matches error and creates the expected node_modules/react symbolic link.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.