6

I can't find any straightforward instructions on this. I've installed node.js and npm, then created a project in its own folder, D:\node_stuff, then cd'd there via cmd (Windows 10) and ran npm install express, npm init. I'm trying to use gifify, and installed its dependencies via npm instead of brew (ffmpeg, imagemagick, giflossy).

  • gifify -h -> 'gifify' is not recognized as an internal or external command, operable program or batch file.
  • node gifify -h -> Error: Cannot find module 'D:\node_stuff\gifify'
  • cd node_modules -> node gifify -h -> nothing happens

What am I doing wrong? Where do I even look - all tutorials with simple search only show how to install packages or build a project - I don't need to build anything, only to use this one module.

3
  • 1
    On Mac/Linux, because you installed the package locally rather than globally, you would typically use npx to run it e.g. npx gifify -h. Not sure this is available on Windows but please try. Commented Sep 22, 2020 at 19:59
  • @jarmod Nice, it worked - I'll see if the rest of functionality works, then you can post it as an answer. Strange how multiple articles didn't mention it. Commented Sep 22, 2020 at 20:01
  • 1
    to add it to path would need to do npm i gifify -g, its in the readme Commented Sep 22, 2020 at 20:03

2 Answers 2

7

You can run npx gifify -h.

Generally, you have two options when installing NPM packages:

  1. install globally e.g. npm install gifify -g
  2. install locally e.g. npm install gifify (or npm install if the package is listed in package.json)

Some packages, when installed, also install a command-line script. For globally-installed packages, that CLI script is installed to a location that is in your PATH and hence you can simply run the bare command e.g. gifify -h. For locally-installed packages, that CLI script is installed locally under the node_modules folder, which is not in your PATH. To run such a script you can use the NPM package executor npx, for example npx gifify -h. This essentially executes the local script from the node_modules/.bin folder.

If your package script, e.g. gifify, relies on third-party executables such as FFMPEG and ImageMagick, then I would install those as regular applications (which will put them on your PATH).

Sign up to request clarification or add additional context in comments.

5 Comments

Ran into other troubles, but likely so will other users: some packages fail to be "found" by node by the module used. For example, npx gifify clip.mp4 -o clip.gif -. "Could not find ffmpeg. Is it installed?" Yes, via npm install ffmpeg, both locally and globally (-g). Solution was choco install ffmpeg. Now another problem: "Could not find convert. Is it installed?" choco didn't work this time, nor did npm; any other 'tricks'?
I'd assume that gifify is execing ffmpeg/convert and because they are not on your PATH it fails to exec them. The gifify package, and others, don't emulate the behavior of npx. You could simply supplement your PATH environment variable with "node_modules\.bin" and then execute gifify -h or npx gifiy -h (assuming that ffmpeg is in node_modules\.bin). For me personally, I'd probably install FFMPEG and ImageMagick globally as standalone executables rather than through NPM and they'd be added to my PATH. Also, watch out that there is a native Windows convert program which is an NTFS utility.
gifify now runs after restarting cmd, but node_modules/convert still not found; is there a "run with debug info" flag? "Not found" isn't telling me much
Believe that convert is part of ImageMagick.
Yeah, installing ImageMagick from here worked, and finally I get to an error that's from the program itself - but not topic of this Q&A. Thanks for the help.
0

I had a similar situation and jarmods answer was very helpful to me.

For the benefit of future readers I have an additional option that I discovered.

You can also create a script in your package.json like this:

"scripts": { //... "gifify": "gifify -h" //... } 

Then at the command line, either (as you prefer):

npm run gifify 

or:

pnpm gifify 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.