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

Using @google-cloud/datastore in Docker project creates cannot find error for grpc #2641

Closed
DaveyEdwards opened this issue Oct 1, 2017 · 5 comments
Assignees
Labels
api: datastore Issues related to the Datastore API.

Comments

@DaveyEdwards
Copy link

DaveyEdwards commented Oct 1, 2017

Environment details

  • OS: Windows 10
  • Node.js version: 6.11.2
  • npm version: 3.10.10
  • google-cloud-node version: 1.1.0

Steps to reproduce

Note I am not using grpc in the project

  1. install @ google-cloud/datastore in Docker app
    I am trying this on base version of: https://github.com/kriasoft/nodejs-api-starter
  2. start server
  3. Get the following error
api_1    | Error: Cannot find module '/usr/src/app/node_modules/@google-cloud/datastore/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64/grpc_node.node'
api_1    |     at Function.Module._resolveFilename (module.js:527:15)
api_1    |     at Function.Module._load (module.js:476:23)
api_1    |     at Module.require (module.js:568:17)
api_1    |     at require (internal/module.js:11:18)
api_1    |     at Object.<anonymous> (/usr/src/app/node_modules/@google-cloud/datastore/node_modules/grpc/src/node/src/grpc_extension.js:30:15)
api_1    |     at Module._compile (module.js:624:30)
api_1    |     at Object.Module._extensions..js (module.js:635:10)
api_1    |     at Module.load (module.js:545:32)
api_1    |     at tryModuleLoad (module.js:508:12)
api_1    |     at Function.Module._load (module.js:500:3)
api_1    | module.js:529
api_1    |     throw err;
api_1    |     ^

If I try and install this into the project with yarn I get an error and can't even install it

$ yarn add @google-cloud/datastore
yarn add v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
warning fsevents@1.1.2: The platform "win32" is incompatible with this module.
info "fsevents@1.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "graphql-relay@0.5.2" has incorrect peer dependency "graphql@^0.5.0 || ^0.6.0 || ^0.7.0 || ^0.8.0-b || ^0.9.0 || ^0.10.0".
error An unexpected error occurred: "EPERM: operation not permitted, lstat 'C:\\Projects\\myiworlds\\myiworlds-backend\\node_modules\\grpc\\package.json'".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Projects\\myiworlds\\myiworlds-backend\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Trying to install google-cloud does the same

$ yarn add google-cloud
yarn add v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
warning fsevents@1.1.2: The platform "win32" is incompatible with this module.
info "fsevents@1.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "graphql-relay@0.5.2" has incorrect peer dependency "graphql@^0.5.0 || ^0.6.0 || ^0.7.0 || ^0.8.0-b || ^0.9.0 || ^0.10.0".
error An unexpected error occurred: "EPERM: operation not permitted, lstat 'C:\\Projects\\myiworlds\\myiworlds-backend\\node_modules\\grpc\\package.json'".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Projects\\myiworlds\\myiworlds-backend\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

I have this working fine with another application that isn't using Docker which is leading me to believe something with Docker is likely the issue.

2017-10-01_10-28-46

@DaveyEdwards DaveyEdwards changed the title Using @google-cloud/datastore in Docker creates cannot find error for grpc Using @google-cloud/datastore in Docker project creates cannot find error for grpc Oct 1, 2017
@DaveyEdwards
Copy link
Author

DaveyEdwards commented Oct 1, 2017

Possible duplicate of
#1820
and it was moved to
grpc/grpc#8860

Although I was not able to get it working with any of the solutions in the thread

@stephenplusplus
Copy link
Contributor

This issue was moved to grpc/grpc#12780

@stephenplusplus
Copy link
Contributor

Thanks for reporting. I've moved the issue to the gRPC repository, as they're likely the right ones to find an answer. Sorry for the trouble.

@stephenplusplus stephenplusplus added the api: datastore Issues related to the Datastore API. label Oct 2, 2017
@koistya
Copy link

koistya commented Oct 3, 2017

@DaveyEdwards you can try to solve it by adding libc6-compat to Dockerfile and Dockerfile.dev. Then run:

$ rm -rf ./node_modules
$ docker-compose build --no-cache
$ docker-compose run --rm --no-deps api yarn
$ docker-compose up

@DaveyEdwards
Copy link
Author

@koistya This worked perfectly thanks!

my dockerfile now looks like:

FROM node:8.6.0-alpine

# Set a working directory
WORKDIR /usr/src/app

# Copy application files
COPY . .

# Install dependencies
RUN apk add --no-cache libsodium libc6-compat && \
  yarn install --production --no-progress && \
  yarn cache clean

# Run the container under "node" user by default
USER node

CMD [ "node", "build/server.js" ]

and the Dockerfile.dev

FROM node:8.6.0-alpine

# Set a working directory
WORKDIR /usr/src/app

# If you have native dependencies, you'll need extra tools
RUN apk add --no-cache make g++ python2 libsodium-dev libc6-compat && \
  npm install -g node-gyp && \
  mkdir -p /home/node/.cache/yarn && \
  chown -R node:node /home/node/.cache/yarn && \
  chmod 777 /home/node/.cache/yarn

VOLUME /home/node/.cache/yarn

# Run the container under "node" user by default
USER node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API.
Projects
None yet
Development

No branches or pull requests

3 participants