Skip to content

"npm: command not found" on fedora 38 #72

@jfhbrook

Description

@jfhbrook

Hello!

I was trying this tool out for a build on COPR, and I ran into an interesting bug on fedora 38!

So when I generate the spec file, the build requires looks like this:

BuildRequires: %{?scl_prefix_nodejs}npm
%if 0%{!?scl:1}
BuildRequires: nodejs-packaging
%endif

The scl prefix seems to include the version of node being used - so in this case, it wants nodejs20-npm, not nodejs-npm. In Fedora 37 this works fine, but on Fedora 38 it causes this error message:

npm: command not found

and I think why that's happening is that nodejs20-npm doesn't install /usr/bin/npm:

$ dnf repoquery -l nodejs20-npm | ag npm$
Last metadata expiration check: 1:54:37 ago on Mon 12 Jun 2023 04:43:08 PM AKDT.
/usr/lib/node_modules_20/npm
/usr/lib/node_modules_20/npm/bin/npm
/usr/lib/node_modules_20/npm
/usr/lib/node_modules_20/npm/bin/npm

That shim seems to be installed with the non-versioned package:

$ dnf repoquery -l nodejs-npm | ag npm$
Last metadata expiration check: 1:56:22 ago on Mon 12 Jun 2023 04:43:08 PM AKDT.
/usr/bin/npm
/usr/lib/node_modules_18/npm
/usr/lib/node_modules_18/npm/bin/npm
/usr/bin/npm
/usr/lib/node_modules_18/npm
/usr/lib/node_modules_18/npm/bin/npm

For the purposes of my build, I got it working with a little bit of sed:

cat "nodejs-${name}.spec" | sed 's/BuildRequires: %{?scl_prefix_nodejs}npm/BuildRequires: nodejs-npm/' > modified.spec
mv modified.spec "nodejs-${name}.spec"

but I think if I were to suggest a patch to npm2rpm, I'd say that you should instead use some macros to call /usr/lib/node_modules_20/npm directly, instead of calling npm and counting on that shim existing.

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions