microsoft / dts-gen

dts-gen creates starter TypeScript definition files for any module or library.
MIT License
2.44k stars 102 forks source link

Can't generate files for scoped packages #125

Open dbnapp opened 5 years ago

dbnapp commented 5 years ago

I realize that @types/storybook__react exists, this problem is really about if I use private scoped packages.

npx dts-gen -m @storybook/react
Unexpected crash! Please log a bug with the commandline you specified.
ENOENT: no such file or directory, open '@storybook/react.d.ts'

if I make a directory for @storybook in my project and run the command I get

npx dts-gen -m @storybook/react
Wrote 3 lines to @storybook/react.d.ts.

which is just a file called react.d.ts inside the @storybook directory I created and has the following contents

/** Declaration file generated by dts-gen */

export = @storybook/react;

it seems to have an error

burtek commented 4 years ago

Try dts-gen@0.6.0

LawnGnome commented 4 years ago

This still fails on 0.6.0, but with a different error:

$ dts-gen -m @private/package -d
Warning: Could not retrieve version/homepage information: HTTP Error 404: Not Found for http://registry.npmjs.org/@private/package

@private/package is obviously a placeholder here, but represents a valid private scoped package that this project depends upon.

nstrelow commented 3 years ago

Did you find a solution to this? And is the problem related to it being private or it being scoped? Mine is both

LawnGnome commented 3 years ago

Did you find a solution to this?

No; this wasn't on the critical path for the project I was working on, so I dropped it, and I no longer work at that company. Sorry!

misha-erm commented 3 years ago

Fails for me too. dts-gen: v0.6.0

➜ dts-gen -m @vizydrop/logger -o                                                                                                                                       20:22:49 
Unexpected crash! Please log a bug with the commandline you specified.
/usr/local/lib/node_modules/dts-gen/bin/lib/run.js:125
        throw e;
        ^

Error: ENOENT: no such file or directory, open '@vizydrop/logger.d.ts'
    at Object.openSync (fs.js:476:3)
    at Object.writeFileSync (fs.js:1467:35)
    at Object.<anonymous> (/usr/local/lib/node_modules/dts-gen/bin/lib/run.js:107:12)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '@vizydrop/logger.d.ts'
}

@vizydrop/logger is a private module here

siddthesquid commented 2 years ago

I got this error for a third party scoped package. If it helps anyone, a quick and dirty workaround was to:

  1. Install your scoped package @org/package. It will show up under node_modules/@org/package
  2. Copy node_modules/@org/package to node_modules/package
  3. Run dts-gen -m package.
  4. Wrap the generated file with declare module @org/package
  5. Delete the node_modules/package folder which you no longer need.
Chappie74 commented 2 years ago

What I found works is, specify a directory with -d and run the command. It's going to throw an error, but still generate the necessary files. You may have to do the same wrapping at step 4 above