How to install grpc-tools js package on ubuntu 18.04 with npm

Viewed 622

I am trying to install grpc-tools package on ubuntu 18.04 with npm. But an error arises. On ubuntu 20.04 everything is ok. How to install it on ubuntu 18.04?

I have Dockerfile:

FROM ubuntu:18.04
RUN apt update && apt install -y --no-install-recommends nodejs npm
RUN npm config set strict-ssl false
RUN npm install grpc-tools@1.11.0

I build docker this way:

docker build .

Getting an error:

Step 4/4 : RUN npm install grpc-tools@1.11.0
 ---> Running in 77d9132ac6af
npm WARN deprecated node-pre-gyp@0.15.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future

> grpc-tools@1.11.0 install /node_modules/grpc-tools
> node-pre-gyp install

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp ERR! install error 
node-pre-gyp ERR! stack Error: unable to get local issuer certificate
node-pre-gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1105:38)
node-pre-gyp ERR! stack     at emitNone (events.js:106:13)
node-pre-gyp ERR! stack     at TLSSocket.emit (events.js:208:7)
node-pre-gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:639:8)
node-pre-gyp ERR! stack     at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38)
node-pre-gyp ERR! System Linux 5.4.0-40-generic
node-pre-gyp ERR! command "/usr/bin/node" "/node_modules/.bin/node-pre-gyp" "install"
node-pre-gyp ERR! cwd /node_modules/grpc-tools
node-pre-gyp ERR! node -v v8.10.0
node-pre-gyp ERR! node-pre-gyp -v v0.15.0
node-pre-gyp ERR! not ok 
unable to get local issuer certificate
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.
npm ERR! Linux 5.4.0-40-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "grpc-tools@1.11.0"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE

npm ERR! grpc-tools@1.11.0 install: `node-pre-gyp install`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the grpc-tools@1.11.0 install script 'node-pre-gyp install'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the grpc-tools package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs grpc-tools
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls grpc-tools
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /npm-debug.log
The command '/bin/sh -c npm install grpc-tools@1.11.0' returned a non-zero code: 1
1 Answers

The problem is that default node version in ubuntu 18.04 is too old. You can update node with:

npm cache clean -f
npm install -g n
n stable
Related