Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pbts cannot find jsdoc #622

Closed
ghost opened this issue Jan 6, 2017 · 7 comments
Closed

pbts cannot find jsdoc #622

ghost opened this issue Jan 6, 2017 · 7 comments

Comments

@ghost
Copy link

ghost commented Jan 6, 2017

protobuf.js version: 6.4.3
OS: windows 10 x64

pbts fails to run, because it cannot find jsdoc module. Maybe affected by #618?

repro step

  1. greeter.proto is Greeter example.

  2. Run node_modules\.bin\pbjs --target static-module --wrap commonjs greeter.proto >greeter.js. This step installs CLI dependency and runs as expected.

  3. Run node_modules\.bin\pbts greeter.js > greeter.d.ts, fails to run.

error output

PS C:\Users\kang\Downloads\test> node_modules\.bin\pbts greeter.js > greeter.d.ts
module.js:471
    throw err;
    ^

Error: Cannot find module 'C:\Users\kang\Downloads\test\node_modules\protobufjs\node_modules\jsdoc\jsdoc.js'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
C:\Users\kang\Downloads\test\node_modules\protobufjs\cli\pbts.js:123
                    throw err;
                    ^

Error: code 1
    at Error (native)
    at ChildProcess.<anonymous> (C:\Users\kang\Downloads\test\node_modules\protobufjs\cli\pbts.js:119:27)
    at emitTwo (events.js:111:20)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
@ghost
Copy link
Author

ghost commented Jan 6, 2017

There is no node_module directory under node_modules/protobufjs, while it exists under node_modules/protobufjs/cli.

@dcodeIO
Copy link
Member

dcodeIO commented Jan 6, 2017

On first run of node_modules\.bin\pbjs it should install all required CLI dependencies, which are:

installing CLI dependencies: chalk@^1.1.3, glob@^7.1.1, jsdoc@^3.4.2, minimist@^1.2.0, tmp@0.0.31, uglify-js@^2.7.5

These are intentionally installed to node_modules\protobufjs\cli\node_modules to make sure that not all dev dependencies from the protobufjs package become installed (npm does this, unfortunately, when not having a package.json and a node_modules directory specifically for the CLI).

When running node_modules\.bin\pbts afterwards (this runs cli\pbts.js), it should be able to find the dependencies in cli\node_modules, but it obviously can't for some reason. Any ideas?

@dcodeIO
Copy link
Member

dcodeIO commented Jan 6, 2017

Found it, hardcoded here.

@ghost
Copy link
Author

ghost commented Jan 6, 2017

https://github.com/dcodeIO/protobuf.js/blob/6.4.3/cli/pbts.js#L98

basedir should be __dirname. Fixed and ran again, pbts gives another error.

Cannot parse the config file C:\Users\kang\Downloads\test\node_modules\protobufjs\cli/jsdoc.types.json: Error: ENOENT: no such file or directory

Where is jsdoc.types.json? Is it in protobuf.js or in jsdoc?

@dcodeIO dcodeIO closed this as completed in c1de05f Jan 6, 2017
@dcodeIO
Copy link
Member

dcodeIO commented Jan 6, 2017

Yeah, because the config is still in the basedir. This required another lookup just for jsdoc. Try with the commit above!

@dcodeIO
Copy link
Member

dcodeIO commented Jan 6, 2017

The latter does the same, just a bit simpler.

@dcodeIO
Copy link
Member

dcodeIO commented Jan 6, 2017

On npm now as 6.4.4, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant