-
Notifications
You must be signed in to change notification settings - Fork 4
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
The programmatic API was removed in npm v8.0.0 #26
Comments
It seems like npm has discontinued the support for programmatic API this is a pity since we can't install packages automatically with npm 8 .... See dracupid/global-npm#7 (comment) and npm/cli#3762 . I'll some do tests to see if we can have a workaround, meanwhile, the only available option is to downgrade to npm 7 |
Any alternative for this @relu91 ? |
For wam currently we are catching the exception and kindly ask the user to manually install the packages (i.e., type |
This is a bad new :(, but with promisify and write in |
Here is an example that works for me /**
* https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback
* https://stackoverflow.com/a/69296792/10850021
*/
const util = require('util');
const exec = util.promisify(require('child_process').exec);
(async () => {
try {
const { stdout, stderr } = await exec('npm pkg get dependencies');
// do something with the dependencies
const dependencies = JSON.parse(stdout);
...
const { stdout: stdout1, stderr: stderr1 } = await exec('npm pkg get peerDependencies -ws');
// do something with the peerDependencies of all workspaces, e.g. set them to a specific version
...
} catch (e) {
console.error(e); // should contain code (exit code) and signal (that caused the termination).
}
})(); |
I ran into an issue when we did a major upgrade to our nestjs application. This is how we were able to solve it. Before upgrade code: import * as npm from "npm"
(async () => {
/*Loading all the needed parameters from AWS*/
})().then(() => {
npm.load(() => npm.run(`start:main`))
}) After upgrade code: import * as child from "child_process"
(async () => {
/*Loading all the needed parameters from AWS*/
})().then(() => {
child.spawn("node", ["dist/main"], {
shell: true,
stdio: "inherit"
})
}) used child_process to directly call file instead of depending on npm cli or npm to call that file. I hope this helps someone. |
Hi,
I can't init the project, working with
$ npm -v: 8.1.2
.Output of
$ npm i @arces-wot/wam -g
:Output of
wam init test
:After that, in the directory that I run init cmd, nothing is generated, the directory is still void.
The text was updated successfully, but these errors were encountered: