问题
I'm creating a module (foo) with an executable. I've used npm link
to make sure the package can be tested
locally. This module has a dependency (bar) with an executable. I want to access this executable inside my executable.
mainProject
|
|- foo
|
|- bar
// cli.js (foo/cli.js)
import { spawnSync } from 'child_process';
async function main(argv: string[]) {
const version = require('../package.json').version;
commander
.command('test')
.action(async () => {
const { stdout, stderr, error } = spawnSync('bar --help');
});
commander.parse(argv);
}
export default main;
If I call foo test
from my main project it fails I get:
Error: spawnSync bar --help ENOENT
来源:https://stackoverflow.com/questions/59357144/npm-package-development-run-executable