【发布时间】:2022-02-06 04:24:26
【问题描述】:
在我的终端中运行它:
npm i --save-dev typescript 'https://gitpkg.now.sh/pylonbot/pylon-sdk-types/runtime' 'https://gitpkg.now.sh/pylonbot/pylon-sdk-types/runtime-discord'
按预期安装软件包。但是,当我尝试使用 child_process 的 execSync 安装这些软件包时,安装失败。
代码:
try {
child_process.execSync(`npm i --save-dev typescript 'https://gitpkg.now.sh/pylonbot/pylon-sdk-types/runtime' 'https://gitpkg.now.sh/pylonbot/pylon-sdk-types/runtime-discord'`);
} catch(e) {
console.log(e);
process.exit();
} finally {
console.log('It worked!');
}
输出:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\me\test\'https:\gitpkg.now.sh\pylonbot\pylon-sdk-types\runtime'/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\me\test\'https:\gitpkg.now.sh\pylonbot\pylon-sdk-types\runtime'\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
有趣的是,它仅在包含 gitpkgs 时才会失败(gitpkg 是一个允许您从 github 子目录安装软件包的工具)
如果这是愚蠢的事情,请提前抱歉,但我无法弄清楚。
【问题讨论】:
标签: node.js npm child-process