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

Error using CLI with protobufjs installed in project due to missing semver #648

Closed
kenny-house opened this Issue Jan 17, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@kenny-house
Contributor

kenny-house commented Jan 17, 2017

protobuf.js version: 6.5.0

Attempting to use the pbjs CLI within a package to generate static module. Error: Cannot find module 'semver' is thrown. Note that pbjs is not installed globally in this instance.

The issue appears to be that semver is not included as a dependency in the package.json (but is instead a devDependency).

npm install protobufjs --save
node_modules/protobufjs/bin/pbjs -t static-module -p ./protos/*.proto -o ./gen/protos.js ./protos/*.proto
installing semver@^5.3.0 (Cannot find module 'semver/package.json')

Error: Cannot find module 'semver'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at PROJECT_PATH/node_modules/protobufjs/cli/util.js:94:22
    at Array.forEach (native)
    at Object.exports.setup (PROJECT_PATH/node_modules/protobufjs/cli/util.js:82:25)
    at Object.<anonymous> (PROJECT_PATH/node_modules/protobufjs/cli/pbjs.js:7:6)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
@kenny-house

This comment has been minimized.

Contributor

kenny-house commented Jan 17, 2017

Ah, I didn't realize the behavior of the CLI util setup function installing missing CLI dependencies.

The solution I have working at the moment is at: master...Kenny-House:semver-dependency

I've separated the semver install into a specific case at the beginning of the setup, as opposed to being one of the cliDependencies. The exact semver version is checked and installed if it is missing or doesn't match.

I'm happy to submit that as a PR, but I'm not familiar enough with this project's constraints and preferences to know if that solution is acceptable.

dcodeIO added a commit that referenced this issue Jan 18, 2017

@dcodeIO

This comment has been minimized.

Owner

dcodeIO commented Jan 18, 2017

Thanks, I've modified the setup stuff accordingly and implemented an explicit check for module directories. Let me know if this is working for you!

dcodeIO added a commit that referenced this issue Jan 18, 2017

@dcodeIO dcodeIO added the bug label Jan 18, 2017

@kenny-house

This comment has been minimized.

Contributor

kenny-house commented Jan 18, 2017

Thanks @dcodeIO, the latest update works great!

Closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment