'electron-packager' 未被识别为内部或外部命令 [英] 'electron-packager' is not recognized as an internal or external command
问题描述
我最近开始使用电子.我通过创建一个 hello world 应用程序(包含文件 index.html、main.js、package.json)成功完成了第一阶段.现在我正在尝试使用 electron-packager 打包应用程序但收到此错误
I recently started using electron. I have successfully completed the 1st phase by creating a hello world app (included files index.html, main.js, package.json). Now I am trying to package the app using electron-packager but getting this error
我遵循的步骤:
- 创建了一个名为 helloworld 的项目目录.
- 使用
npm init
命令初始化项目目录. - 然后使用
npm install electron --save-dev
安装电子. - 然后将 javascript 和 html 文件分别创建为 main.js 和 index.html.
- 然后使用
npm start
执行应用程序. - 然后使用
npm install electron-packager
安装 electron-packager. - 现在问题出现在这一步,当我尝试使用命令
electron-packager 打包应用程序时.
- Created a project directory named helloworld.
- Initialized the project directory using
npm init
command. - Then installed electron using
npm install electron --save-dev
. - Then created the javascript and html files as main.js and index.html respectively.
- Then used
npm start
to execute the application. - Then installed electron-packager using
npm install electron-packager
. - Now the problem is coming in this step when i am trying to pacakge the app using command
electron-packager .
推荐答案
执行全局包安装:
npm install -g electron-packager
-g
标志告诉 NPM 全局安装包,这使得命令 electron-packager
在你的 PATH 中可用.
The -g
flag tells NPM to install the package globally which makes the command electron-packager
available in your PATH.
如果您不想进行全局安装,可以在本地安装并使用 npx
运行.
If you don't want to do a global install you can install it locally and run with npx
.
npm install -D electron-packager
npx electron-packager .
<小时>
或者,您可以直接从 node_modules 文件夹中引用它(不推荐).
Alternatively, you can reference it straight from the node_modules folder (not recommended).
./node_modules/electron-packager/cli.js
这篇关于'electron-packager' 未被识别为内部或外部命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!