'电子打包程序'未被识别为内部或外部命令 [英] 'electron-packager' is not recognized as an internal or external command
问题描述
我最近开始使用电子。我已经通过创建一个hello world应用程序(包含文件index.html,main.js,package.json)成功完成了第一阶段。现在,我正在尝试使用电子打包程序打包应用程序,但出现此错误
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 electronic安装电子- save-dev
。 - 然后分别创建了javascript和html文件,分别为main.js和index.html。
- 然后使用
npm start
执行应用程序。 - 然后使用
npm install electronic-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 .
推荐答案
Pe进行全局软件包安装:
Perform a global package install:
npm install -g electron-packager
-g
标志告诉NPM全局安装软件包,从而使PATH中可用的命令 electron-packager
。
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
这篇关于'电子打包程序'未被识别为内部或外部命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!