protobuf.js icon indicating copy to clipboard operation
protobuf.js copied to clipboard

Installation errors running CLI

Open jakelauer opened this issue 5 years ago • 16 comments

protobuf.js version: 6.8.8

Expected: Protobufjs runs and installs dependencies Actual: Protobufjs fails to install dependencies

installing jsdoc@^3.5.5
installing uglify-js@^3.3.25
installing espree@^3.5.4
child_process.js:669
    throw err;
    ^
Error: Command failed: npm --silent install jsdoc@^3.5.5 uglify-js@^3.3.25 espree@^3.5.4
    at checkExecSyncError (child_process.js:630:11)
    at Object.execSync (child_process.js:666:15)
    at modInstall (D:\Project\node_modules\protobufjs\cli\util.js:129:19)
    at Object.exports.setup (D:\Project\node_modules\protobufjs\cli\util.js:156:5)
    at Object.<anonymous> (D:\Project\node_modules\protobufjs\cli\pbjs.js:7:6)
    at Module._compile (internal/modules/cjs/loader.js:1157:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
    at Module.load (internal/modules/cjs/loader.js:1001:32)
    at Function.Module._load (internal/modules/cjs/loader.js:900:14)
    at Module.require (internal/modules/cjs/loader.js:1043:19) {

Any ideas for how to mitigate this?

jakelauer avatar Mar 06 '20 19:03 jakelauer

Note: We have multiple machines failing with this error

jakelauer avatar Mar 06 '20 19:03 jakelauer

The CLI and the browser runtime source code are in one package. Most people are only using protobuf.js for their runtime dep. For providing a smaller installed size, the author does not install the CLI's dependencies by default. Only when the CLI is used will it check whether it's dependencies were installed. If not, it will start a child process to install them. The child process would execute an npm install ... command. But that may cause problems such as insufficient permissions in system or failed to find NPM due to environment variables.

create-share avatar Mar 10 '20 04:03 create-share

Is there a mitigation for this? We tried including the libraries in our own package.json but it still installs them anyway.

jakelauer avatar Mar 10 '20 05:03 jakelauer

Is there a mitigation for this? We tried including the libraries in our own package.json but it still installs them anyway.

Because the libraries are installed in <root>/cli/node_modules instead of <root>/node_modules. You could remove the <root>/cli/package.json and remove the .setup() caller.

https://github.com/protobufjs/protobuf.js/blob/master/cli/pbjs.js#L7 https://github.com/protobufjs/protobuf.js/blob/master/cli/pbts.js#L8

create-share avatar Mar 10 '20 06:03 create-share

I don't have the option to modify the files inside node_modules as this issue is happening during build on a machines that run npm install for every build.

jakelauer avatar Mar 11 '20 18:03 jakelauer

This is so annoying. Installing packages dynamically!? it should be avoided.

cainiaokan avatar Apr 19 '20 15:04 cainiaokan

Agreed @cainiaokan . It's easy to avoid because NPM is specifically built the way it's built to avoid things like this.

jakelauer avatar Apr 19 '20 15:04 jakelauer

This is so annoying. Installing packages dynamically!? it should be avoided.

Any update on this? That is 100% accurate in that it should be avoided

ssilve1989 avatar Jul 13 '20 14:07 ssilve1989

add espree@^3.5.4 to devDependencies manually and try again

papirosko avatar Aug 05 '20 13:08 papirosko

  "devDependencies": {
    ...
    "estraverse": "^5.1.0",
    "protobufjs": "^6.10.1",
    "estraverse": "^5.1.0",
    "semver": "^7.1.2",
    "uglify-js": "^3.7.7",
    "tmp": "^0.2.0",
    "chalk": "^4.0.0",
    "jsdoc": "^3.6.3"
    ... 
   }

papirosko avatar Aug 05 '20 13:08 papirosko

Any update?

dreamerblue avatar Oct 19 '20 13:10 dreamerblue

It looks like there's a PR that could fix this by divorcing the CLI from the main package. Last updated 3 days ago: https://github.com/protobufjs/protobuf.js/pull/1234

jakelauer avatar Oct 19 '20 17:10 jakelauer

Same problem with version 6.11.2. installing jsdoc@^3.6.3 installing uglify-js@^3.7.7

Somepub avatar Nov 26 '21 11:11 Somepub

Does not happen on version 6.11.2 under node 14.17. I fixed my issue by bumping node (was 10) + protobufjs (was 6.8.8).

github-mickael-leclerc avatar Jan 24 '22 12:01 github-mickael-leclerc

Fixed for me with npm i -D installing jsdoc@^3.6.3

lorensr avatar Apr 03 '22 02:04 lorensr

Any solution? Now I fixed it by npm i -D installing jsdoc@^3.6.3 uglify-js@^3.3.25 espree@^3.5.4 escodegen@^1.9.1

Chance722 avatar May 05 '22 02:05 Chance722