Skip to content

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

@kenny-house

Description

@kenny-house

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions