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

Use integrated npm? #70

Closed
Enet4 opened this issue Jul 1, 2021 · 1 comment · Fixed by #92
Closed

Use integrated npm? #70

Enet4 opened this issue Jul 1, 2021 · 1 comment · Fixed by #92

Comments

@Enet4
Copy link

Enet4 commented Jul 1, 2021

If the version of Node.js installed is v12.18.3 or higher, attempting to run the task web-assets:jseNpmNodeModules on a project containing web assets (using the Node js engine) can fail because the outdated npm webjar.

[error] npm ERR! Windows_NT 10.0.19042
[error] npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\...\\myproject\\project\\target\\node-modules\\webjars\\npm\\lib\\npm.js" "update" "--prefix" "C:\\...\\myproject"
[error] npm ERR! node v12.22.1
[error] npm ERR! npm  vundefined
[error]
[error] npm ERR! cb.apply is not a function
[error] npm ERR!
[error] npm ERR! If you need help, you may report this error at:
[error] npm ERR!     <https://github.com/npm/npm/issues>
[error]
[error] npm ERR! Please include the following file with any support request:
[error] npm ERR!     C:\...\AppData\Roaming\npm-cache\_logs\2021-06-30T16_30_17_259Z-debug.log
[trace] Stack trace suppressed: run last web-assets:jseNpmNodeModules for the full output.
[error] (web-assets:jseNpmNodeModules) Problems with NPM resolution. Aborting build.

The stack trace provided via last web-assets:jseNpmNodeModules narrows it down to this component.

java.lang.RuntimeException: Problems with NPM resolution. Aborting build.
        at scala.sys.package$.error(package.scala:27)
        at com.typesafe.sbt.jse.SbtJsEngine$$anonfun$2$$anonfun$3.apply(SbtJsEngine.scala:121)
        at com.typesafe.sbt.jse.SbtJsEngine$$anonfun$2$$anonfun$3.apply(SbtJsEngine.scala:103)
        at sbt.FileFunction$$anonfun$cached$1.apply(Tracked.scala:253)
        at sbt.FileFunction$$anonfun$cached$1.apply(Tracked.scala:253)
        at sbt.FileFunction$$anonfun$cached$2$$anonfun$apply$3$$anonfun$apply$4.apply(Tracked.scala:267)
        at sbt.FileFunction$$anonfun$cached$2$$anonfun$apply$3$$anonfun$apply$4.apply(Tracked.scala:263)
        at sbt.Difference.apply(Tracked.scala:224)
        at sbt.Difference.apply(Tracked.scala:206)
        at sbt.FileFunction$$anonfun$cached$2$$anonfun$apply$3.apply(Tracked.scala:263)
        at sbt.FileFunction$$anonfun$cached$2$$anonfun$apply$3.apply(Tracked.scala:262)
        at sbt.Difference.apply(Tracked.scala:224)
        at sbt.Difference.apply(Tracked.scala:200)
        at sbt.FileFunction$$anonfun$cached$2.apply(Tracked.scala:262)
        at sbt.FileFunction$$anonfun$cached$2.apply(Tracked.scala:260)
        at com.typesafe.sbt.jse.SbtJsEngine$$anonfun$2.apply(SbtJsEngine.scala:129)
        at com.typesafe.sbt.jse.SbtJsEngine$$anonfun$2.apply(SbtJsEngine.scala:90)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
        at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
        at sbt.std.Transform$$anon$4.work(System.scala:63)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
        at sbt.Execute.work(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
        at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
        at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        ...

(I could not make a minimal example of this yet; please let me know if it is important)

Trying to update this webjar seems to bring other issues as well (typesafehub/npm#25). But the way I see it, it makes much more sense nowadays to use the npm which is already installed alongside Node.js. The latest LTS (14) comes with npm v6 and the latest stable (16) comes with npm v7, and delivering npm alongside Node.js has been a thing for several years. They are made available as commands both on Windows and Unix-like systems, so that calling npm is enough if the path environment variable is well set.

I believe that relying on the version that is expected to be the most compatible with the installed Node.js would be a good way forward to prevent further stagnation. What do you think about this? For the time being, any guidance in modifying sbt-js-engine and typesafe/npm to work like this would be rather appreciated, as my experience in Scala is a bit thin.

@mkurz
Copy link
Member

mkurz commented May 18, 2023

Starting with version 1.3.0, when using a local installed js engine that supports node, sbt-js-engine tries to detect the systems npm command and will use it instead of the npm webjars.
This is the new default and can be disabled with npmPreferSystemInstalledNpm := false, to keep using the webjar npm, no matter what the engine is.

Also, starting with 1.3.0, it will be possible to set which npm subcommand is used by setting npmSubcommand := NpmSubcommand.Install (available options are Install, Update, Ci). update will stay the default however.

BTW: The npm project is archived and it has been folded into sbt-js-engine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants