Wong Manlok
Wong Manlok

Reputation: 387

Google-Cloud module install fail in node.js

I setup some module in my server environment using Node.js. I need to install the google-cloud module to do the storage.

I am using MacOS, my environment stats:

Here is my package.json

{
  "name": "jsontool",
  "version": "0.0.0",
  "private": true,
  "scripts": {
  "start": "nodemon -e js app.js"
  },
  "dependencies": {
  "async": "^2.6.1",
  "cookie-parser": "~1.4.3",
  "debug": "~2.6.9",
  "download-file": "^0.1.5",
  "ejs": "^2.6.1",
  "express": "~4.16.0",
  "fs": "^0.0.1-security",
  "fs-extra": "^7.0.1",
  "http-errors": "^1.6.3",
  "jade": "~1.11.0",
  "jwt-simple": "^0.5.1",
  "memcached-promisify": "^2.0.0",
  "moment": "^2.22.2",
  "morgan": "~1.9.0",
  "nodemon": "^1.17.5",
  "pg-promise": "^8.4.5",
  "shortid": "^2.2.14",
  "winston": "2.4.3"
  }
}

$ sudo yarn add google-cloud
yarn add v1.6.0
(node:81069) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[1/4] 🔍 Resolving packages...
warning [email protected]: The google-cloud package has been deprecated. We strongly recommend installing individual API packages, such as @google-cloud/storage. For a list of Google Cloud Platform API specific packages please visit
https://cloud.google.com/nodejs/docs/reference/libraries
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 📃 Building fresh packages...
[1/1] ⠂ google-cloud
[-/1] ⠂ waiting...
[-/1] ⠂ waiting...
[-/1] ⠂ waiting...
error /Users/manlokwong/Desktop/BeastQuestServer/bq_server/node_modules/google-cloud: Command failed.
Exit code: 255
Command: node scripts/preinstall.js
Arguments:
Directory:
/Users/manlokwong/Desktop/BeastQuestServer/bq_server/node_modules/google-cloud

I used many ways to install the module. But not work.

Upvotes: 1

Views: 1054

Answers (1)

John Hanley
John Hanley

Reputation: 81356

google-cloud is deprecated. Do not use it.

npm install --save @google-cloud/storage

There are similar packages for the other GCP services.

Note: In node.js SDK version 2.x, the method of initializing the SDK changed.

// Imports the Google Cloud client library
const {Storage} = require('@google-cloud/storage');

// Your Google Cloud Platform project ID
const projectId = 'YOUR_PROJECT_ID';

// Creates a client
const storage = new Storage({
  projectId: projectId,
});

Upvotes: 2

Related Questions