You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to node2nix the following node-packages.json but ran into an issue where node2nix tries to download NPM sources for the wrong package in the case of having specified both an npm: alias and semantic version range for the package.
Reproducing the issue
Node.js v20.12.2
node2nix 1.11.1 (commit 315e1b8)
My package.json contains the following dependencies:
$ npm i --lockfile-version 2
$ nix run nixpkgs#nodePackages.node2nix -- -i package-lock.json
fetching local directory: ./. from .
info attempt registry request try #1 at 4:19:52 PM
http request GET https://registry.npmjs.org/abcd
http 200 https://registry.npmjs.org/abcd
Cannot resolve version: abcd@>=1.69.0 <1.70.0
node2nix tries to download a package abcd which doesn't exist. I expected it to download @codingame/monaco-vscode-api instead.
Analysis
The issue seems to be caused by NPMRegistrySource receiving an already parsed versionSpec (which is missing the npm:... prefix) from Source.constructSource.
Replacing parsedVersionSpec with versionSpec on line 51 seems to resolve the issue.
Clearly, NPMRegistrySource is responsible for the parsing of the semantic versions so this is an obvious mistake in constructSource.
The output for a successful run:
$ nix run github:xhalo32/node2nix/fix-versionSpec -- -i package-lock.json
fetching local directory: ./. from .
info attempt registry request try #1 at 4:35:23 PM
http request GET https://registry.npmjs.org/@codingame%2Fmonaco-vscode-api
http 200 https://registry.npmjs.org/@codingame%2Fmonaco-vscode-api
info attempt registry request try #1 at 4:35:24 PM
http request GET https://registry.npmjs.org/monaco-editor
http 200 https://registry.npmjs.org/monaco-editor
info attempt registry request try #1 at 4:35:25 PM
http request GET https://registry.npmjs.org/vscode-textmate
http 200 https://registry.npmjs.org/vscode-textmate
info attempt registry request try #1 at 4:35:25 PM
http request GET https://registry.npmjs.org/vscode-oniguruma
http 200 https://registry.npmjs.org/vscode-oniguruma
I was trying to
node2nix
the followingnode-packages.json
but ran into an issue wherenode2nix
tries to download NPM sources for the wrong package in the case of having specified both annpm:
alias and semantic version range for the package.Reproducing the issue
My
package.json
contains the following dependencies:And after running the following commands
node2nix
tries to download a packageabcd
which doesn't exist. I expected it to download@codingame/monaco-vscode-api
instead.Analysis
The issue seems to be caused by
NPMRegistrySource
receiving an already parsedversionSpec
(which is missing thenpm:...
prefix) fromSource.constructSource
.Replacing
parsedVersionSpec
withversionSpec
on line 51 seems to resolve the issue.Clearly,
NPMRegistrySource
is responsible for the parsing of the semantic versions so this is an obvious mistake inconstructSource
.The output for a successful run:
Testing & PR
Adding a new line in
tests.json
:leads to the tests failing as expected:
PR: #332
The text was updated successfully, but these errors were encountered: