'electron-packager' is not recognized as an internal or external command

Sidharth Gusain picture Sidharth Gusain · Jul 14, 2017 · Viewed 24.6k times · Source

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

electron-packager error

Steps I have followed:

  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 .

Answer

AlienHoboken picture AlienHoboken · Jul 14, 2017

Perform a global package install:

npm install -g electron-packager

The -g flag tells NPM to install the package globally which makes the command electron-packager available in your PATH.


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 .

Alternatively, you can reference it straight from the node_modules folder (not recommended).

./node_modules/electron-packager/cli.js