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

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

问题描述

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

我遵循的步骤:

  1. 创建了一个名为 helloworld 的项目目录.
  2. 使用 npm init 命令初始化项目目录.
  3. 然后使用 npm install electron --save-dev 安装电子.
  4. 然后将 javascript 和 html 文件分别创建为 main.js 和 index.html.
  5. 然后使用 npm start 执行应用程序.
  6. 然后使用 npm install electron-packager 安装 electron-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 .

推荐答案

执行全局包安装:

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屋!

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