make npm.load re-evaluate the cwd each time it is called #9059
Comments
I see that Meteor uses child_process to manipulate the CLI version on NPM. Maybe that's what I'll have to do. It would be cool to easily change npm dir programmatically though. |
Aha, found the solution that (as far as my case goes) works: Meteor.wrapAsync((callback) => {
npm.load({ prefix: DIR_ONE }, callback)
})()
Meteor.wrapAsync((callback) => {
npm.commands.install(DIR_ONE, [], callback)
})()
...
Meteor.wrapAsync((callback) => {
npm.load({ prefix: DIR_TWO }, callback)
})()
Meteor.wrapAsync((callback) => {
npm.commands.install(DIR_TWO, [], callback)
})() Now, I don't know if the |
Actually, re-opening, as I think that the second call to |
The current programmatic API for npm is unsupported for use outside itself, and there are no guarantees that it will remain stable or has any particular fitness for purpose. If you want to invoke multiple npm commands from another program, the best thing to do is to call npm as a child process twice. At some point, we'll have a better interface for using the installer programmatically, but we're not there yet. As such, I'm closing this. |
I'd like to change the cwd of npm after it's been loaded. For example, I've got something like this, where I run
npm.load
andnpm.command.install
twice,Meteor.wrapAsync
just causes the execution to be "synchronous":The second time, npm doesn't install inside of DIR_TWO as expected. How can we change npm's cwd?
The text was updated successfully, but these errors were encountered: