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

Doesn't work with Node 16 #481

Open
danners opened this issue Nov 16, 2021 · 7 comments
Open

Doesn't work with Node 16 #481

danners opened this issue Nov 16, 2021 · 7 comments

Comments

@danners
Copy link

danners commented Nov 16, 2021

The new npm version shipping with node 16 seems to have changed some thinks required by npm-resolver:

Stack trace:
NestedError: Could not require module 'npm'
at requireg (C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower-npm-resolver\node_modules\requireg\lib\requireg.js:14:11)
at Object. (C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower-npm-resolver\dist\npm_load.js:28:11)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower-npm-resolver\dist\npm\versions.js:30:15)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
Caused By: Error: The programmatic API was removed in npm v8.0.0
at Object. (C:\Program Files\nodejs\node_modules\npm\index.js:4:9)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at requireg (C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower-npm-resolver\node_modules\requireg\lib\requireg.js:12:12)
at Object. (C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower-npm-resolver\dist\npm_load.js:28:11)
at Module._compile (node:internal/modules/cjs/loader:1101:14)

Console trace:
Error
at StandardRenderer.error (C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower\lib\renderers\StandardRenderer.js:88:37)
at Logger. (C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower\lib\bin\bower.js:113:30)
at Logger.emit (node:events:390:28)
at Logger.emit (C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower\lib\node_modules\bower-logger\lib\Logger.js:29:39)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower\lib\commands\index.js:49:24
at _rejected (C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower\lib\node_modules\q\q.js:864:24)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower\lib\node_modules\q\q.js:890:30
at Promise.when (C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower\lib\node_modules\q\q.js:1142:31)
at Promise.promise.promiseDispatch (C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower\lib\node_modules\q\q.js:808:41)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower\lib\node_modules\q\q.js:624:44
System info:
Bower version: 1.8.12
Node version: 16.13.0
OS: Windows_NT 10.0.17763 x64

@ernstki
Copy link

ernstki commented Feb 22, 2022

The key part is

 Caused By: Error: The programmatic API was removed in npm v8.0.0

So for those who arrive at this issue looking for a workaround, downgrading to NPM 7.x is one possible workaround. That's what I resorted to in the end.

On my platform—macOS with MacPorts—I can choose the NPM version independent of the Node version, to a limited extent. Your situation may not be as flexible, particularly if you are getting an all-in-one package from nodejs.org.

Even though the change was merged in October 2021, it might be helpful to keep an eye on npm/cli#3762 (the PR that dropped support for this API) for discussions of workarounds. Or just if you want to commiserate with others affected by the change.

References:

@mjeanroy
Copy link
Owner

Thanks @ernstki, I don't know how to solve this issue yet, except by re-implementing how to fetch packages from scratch :/

@ernstki
Copy link

ernstki commented Jun 1, 2022

Oh, no hard feelings. This is a tough one.

Mostly wanted to document a workaround here so I can refer back to this issue as my "notes" next time I run into this problem. :)

@longevitytina
Copy link

longevitytina commented Feb 9, 2023

Hiya, any updates on this? Just tried to update to Node 18, same issue as original with npm -v 9.3.1
Caused By: Error: The programmatic API was removed in npm v8.0.0 😢

@kemrop
Copy link

kemrop commented May 16, 2023

Tagging along, running into the same issue. Node 16.19.1 npm v8.19.3

@ibcooley
Copy link

@kemrop I've just worked to get this working for our node instance. we're moving to the latest LTS, which is Node 18. You could try pulling the source code from here, or adding it to your node packages, and see if it works for you.

npm install https://github.com/ibcooley/bower-npm-resolver

@mjeanroy I've created a pull request for these changes to be merged into the master repository.

@kemrop
Copy link

kemrop commented May 17, 2023

@ibcooley, Thanks this worked for me.

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

No branches or pull requests

6 participants