Google Cloud Platform tutorial - problem storing data in a datastore

I’m trying to follow Particle’s tutorial for GCP, and got stuck in the use case - storing data in a datastore. I suspect it’s because it requires Node 6, but they are up to Node 10. When I run npm install, I get a ton o’ errors, such as:

node-pre-gyp info it worked if it ends with ok
node-pre-gyp verb cli [ '/usr/local/bin/node',
node-pre-gyp verb cli   '/Users/me/Downloads/google-cloud-datastore-tutorial-master/node_modules/@google-cloud/compute/node_modules/grpc/node_modules/.bin/node-pre-gyp',
node-pre-gyp verb cli   'install',
node-pre-gyp verb cli   '--fallback-to-build' ]
node-pre-gyp info using node-pre-gyp@0.6.28
node-pre-gyp info using node@8.11.4 | darwin | x64
node-pre-gyp verb command install []
node-pre-gyp info check checked for "/Users/me/Downloads/google-cloud-datastore-tutorial-master/node_modules/@google-cloud/compute/node_modules/grpc/src/node/extension_binary/grpc_node.node" (not found)
node-pre-gyp http GET https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v0.14.1/node-v57-darwin-x64.tar.gz
node-pre-gyp http 403 https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v0.14.1/node-v57-darwin-x64.tar.gz
node-pre-gyp ERR! Tried to download: https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v0.14.1/node-v57-darwin-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for grpc@0.14.1 and node@8.11.4 (node-v57 ABI) (falling back to source compile with node-gyp) 
node-pre-gyp http 403 status code downloading tarball https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v0.14.1/node-v57-darwin-x64.tar.gz

Followed by ...

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/me/Downloads/google-cloud-datastore-tutorial-master/node_modules/@google-cloud/compute/node_modules/grpc/src/node/extension_binary/grpc_node.node" "--module_name=grpc_node" "--module_path=/Users/me/Downloads/google-cloud-datastore-tutorial-master/node_modules/@google-cloud/compute/node_modules/grpc/src/node/extension_binary"
gyp ERR! cwd /Users/me/Downloads/google-cloud-datastore-tutorial-master/node_modules/@google-cloud/compute/node_modules/grpc
gyp ERR! node -v v8.11.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/me/Downloads/google-cloud-datastore-tutorial-master/node_modules/@google-cloud/compute/node_modules/grpc/src/node/extension_binary/grpc_node.node --module_name=grpc_node --module_path=/Users/me/Downloads/google-cloud-datastore-tutorial-master/node_modules/@google-cloud/compute/node_modules/grpc/src/node/extension_binary' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/me/Downloads/google-cloud-datastore-tutorial-master/node_modules/@google-cloud/compute/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Darwin 17.7.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/me/Downloads/google-cloud-datastore-tutorial-master/node_modules/@google-cloud/compute/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/me/Downloads/google-cloud-datastore-tutorial-master/node_modules/@google-cloud/compute/node_modules/grpc
node-pre-gyp ERR! node -v v8.11.4
node-pre-gyp ERR! node-pre-gyp -v v0.6.28
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/me/Downloads/google-cloud-datastore-tutorial-master/node_modules/@google-cloud/compute/node_modules/grpc/src/node/extension_binary/grpc_node.node --module_name=grpc_node --module_path=/Users/me/Downloads/google-cloud-datastore-tutorial-master/node_modules/@google-cloud/compute/node_modules/grpc/src/node/extension_binary' (1)
npm WARN particle-google-cloud-datastore-tutorial@0.0.1 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grpc@0.14.1 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the grpc@0.14.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Any hints as to how to modify the project to work with a more up-to-date version of Node, or what to do to get rid of these errors? I’m not keen on downgrading, as I am assuming that there have been security enhancements since 6.

That tutorial has not been updated to support a newer version of node. One option is to use a node version manager, like nvm on the Mac, though there are many others, to allow multiple versions of node to be installed.

However, you may want to try this tutorial instead. It also includes information on deploying your node app to Google Cloud App Engine or using Google Cloud Functions with pub/sub.

This looks excellent! I am looking forward to working through this, thank you so much for writing it. Is it on particle.io? It seems worthy …

I finally found enough time to start working through this. The first part was a masterpiece of clear exposition, but in the Cloud Functions to Datastore Example section, I received a (fairly clear) error message: “There was an error storing the event { Error: 5 NOT_FOUND: The project test2-123456 does not exist or it does not contain an active Cloud Datastore database.” Was that prescribed in the previous tutorial and just not mentioned here?

It turns out that if I just followed the instructions that followed the error message in the log – “Please visit http://console.cloud.google.com to create a project or https://console.cloud.google.com/datastore/setup?project=test2-123456 to add a Cloud Datastore database.” – that I was able to create one, and now data seem to be flowing into my Datastore.

However, I would still lobby for the inclusion of instructions to create the database in advance …

1 Like