node.jstypescripttypescript-definitions

dts-gen: fails to find globally installed modules


I have installed dts-gen globally

npm i -g dts-gen

I installed the target module globally

npm i -g jhipster-core

When I run

dts-gen -m jhipster-core -o

I get the following output:

Couldn't load module "jhipster-core". Please install it globally (npm install -g jhipster-core) and try again.


I am working on a Windows 10 PC and executing the commands on the windows command prompt.


Solution

  • Installing NPM modules globally is usually a bad idea - you will eventually get into weird situations when the globally installed version accidentally gets used instead of the version specified in some package.json file.

    But in this case, the problem seems to be that "jhipster-core" requires the "chalk" module, but does not list it in package.json dependencies.

    This worked for me (just run it in some empty directory):

    npm install dts-gen jhipster-core chalk
    ./node_modules/.bin/dts-gen -m jhipster-core