bower-npm-resolver
bower-npm-resolver copied to clipboard
Doesn't work with Node 16
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.
Console trace:
Error
at StandardRenderer.error (C:\Users\Administrator\AppData\Roaming\npm\node_modules\bower\lib\renderers\StandardRenderer.js:88:37)
at Logger.
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:
- feat: drop node 10, 11, and programmatic api #3762 - npm/cli
- via Globally installed NPM version 8 causes "Cannot find module 'npm'" #7 - dracupid/global-npm
Thanks @ernstki, I don't know how to solve this issue yet, except by re-implementing how to fetch packages from scratch :/
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. :)
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
😢
Tagging along, running into the same issue. Node 16.19.1 npm v8.19.3
@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.
@ibcooley, Thanks this worked for me.