【发布时间】:2020-12-31 22:54:09
【问题描述】:
当我在捆绑的电子应用程序中运行 npm install 时,它会引发错误:/bin/sh: npm: command not found。
然后我使用shelljs 来检查shell.which('npm') 是否可以使用npm 命令,它返回false。
npm 会被捆绑到最终包中吗?如果 npm 没有捆绑在电子应用程序中,我如何从电子应用程序安装节点模块?
【问题讨论】:
当我在捆绑的电子应用程序中运行 npm install 时,它会引发错误:/bin/sh: npm: command not found。
然后我使用shelljs 来检查shell.which('npm') 是否可以使用npm 命令,它返回false。
npm 会被捆绑到最终包中吗?如果 npm 没有捆绑在电子应用程序中,我如何从电子应用程序安装节点模块?
【问题讨论】:
electron-builder 等软件包会为您处理此问题。如果有 npm 无法安装的本机模块,您必须遵循一些 their recommendations 来设置这些模块。不过,大多数应用不需要这些额外步骤。
我有一个electron template,它使用 electron-builder 并为电子应用程序实施最佳安全实践,以防您需要应用程序模板。
【讨论】: