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

nodejs@22.0.0: npm script missing #5755

Closed
3 tasks done
pezcode opened this issue Apr 26, 2024 · 4 comments
Closed
3 tasks done

nodejs@22.0.0: npm script missing #5755

pezcode opened this issue Apr 26, 2024 · 4 comments
Labels
bug Something isn't working upstream Waiting for upstream (the developers of the software) to fix the problem

Comments

@pezcode
Copy link

pezcode commented Apr 26, 2024

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues/PRs to ensure it has not already been reported or fixed.
  • I have verified that I am using the latest version of Scoop and corresponding bucket.

Package Name

nodejs

Expected/Current Behaviour

Installing nodejs (22.0.0) and then running npm produces:

node:internal/modules/cjs/loader:1205
  throw err;
  ^

Error: Cannot find module 'C:\Users\chris\scoop\persist\nodejs\bin\node_modules\npm\bin\npm-cli.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1202:15)
    at Module._load (node:internal/modules/cjs/loader:1027:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:187:14)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Steps to Reproduce

scoop install nodejs
npm

Possible Solution

No fix, but two workarounds:

  • install old version scoop install nodejs@21.7.3
  • install nodejs-lts instead

Scoop and Buckets Version

Current Scoop version:
d285bb08 (HEAD -> master, tag: v0.4.1, origin/master, origin/HEAD) chore(release): Bump to version 0.4.1 (#5924)

'main' bucket:
24cfbb1e5 (HEAD -> master, origin/master, origin/HEAD) rtools: Update to version 4.4.6104.6039 (#5753)

Scoop Config

last_update           scoop_repo                              scoop_branch
-----------           ----------                              ------------
4/26/2024 12:27:33 PM https://github.com/ScoopInstaller/Scoop master

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Additional Softwares

No response

@pezcode pezcode added the bug Something isn't working label Apr 26, 2024
@NemoStein
Copy link

Same issue here

@maokwen
Copy link
Contributor

maokwen commented Apr 27, 2024

This line introduces the error:

"Set-Content -Value \"prefix=$persist_dir\\bin`ncache=$persist_dir\\cache\" -Path \"$dir\\node_modules\\npm\\npmrc\""

Possible Solution:

  • update persist path defined in manifest.json, or:
  • change %scoop%\apps\nodejs\22.0.0\node_modules\npm\npmrc, unset prefix variable.

@arpsmack
Copy link

npm.cmd only uses npm-cli from the prefix dir if it actually exists, and otherwise falls back to using npm-cli from the node dir. npm.ps1 always tries to use npm-cli from the prefix dir.

This seems like a bug in node.

As a workaround, using npm.cmd directly works fine.

PS C:\> npm.cmd --version
10.5.1

Or you could add this to npm.ps1:

$npmprefixclijs="$npmprefix/node_modules/npm/bin/npm-cli.js"

+# Fall back to using npm from the node dir if it doesn't exist in the prefix dir
+if (-not (test-path $npmprefixclijs)) {
+  $npmprefixclijs = "$nodedir/node_modules/npm/bin/npm-cli.js"
+}

which also seems to work

PS C:\> npm --version
10.5.1

Seems like this requires a fix in node though. Setting the node prefix path to point to a persisted path seems like the right thing for the scoop package to be doing.

@chawyehsu
Copy link
Member

chawyehsu commented Apr 28, 2024

It's a npm's bug, see nodejs/node#52682, you may try workarounds mentioned above (or manually remove npm|npx.ps1 to let it fallback to npm|npx.cmd) before they fixing it.

@chawyehsu chawyehsu added the upstream Waiting for upstream (the developers of the software) to fix the problem label Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Waiting for upstream (the developers of the software) to fix the problem
Projects
None yet
Development

No branches or pull requests

5 participants