'电子打包程序'未被识别为内部或外部命令 [英] 'electron-packager' is not recognized as an internal or external command

查看:66
本文介绍了'电子打包程序'未被识别为内部或外部命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用电子。我已经通过创建一个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

我遵循的步骤:


  1. 创建了一个名为helloworld的项目目录。

  2. 使用 npm init 命令初始化项目目录。

  3. 然后使用 npm install electronic安装电子- save-dev

  4. 然后分别创建了javascript和html文件,分别为main.js和index.html。

  5. 然后使用 npm start 执行应用程序。

  6. 然后使用 npm install electronic-packager安装电子包装程序

  7. 现在,当我尝试使用命令 electron-packager打包应用程序时,问题就出现了。

  1. Created a project directory named helloworld.
  2. Initialized the project directory using npm init command.
  3. Then installed electron using npm install electron --save-dev.
  4. Then created the javascript and html files as main.js and index.html respectively.
  5. Then used npm start to execute the application.
  6. Then installed electron-packager using npm install electron-packager.
  7. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆