node.js - Node.js 中的 Google-Cloud 模块安装失败

标签 node.js npm google-cloud-platform yarnpkg

我使用 Node.js 在服务器环境中设置了一些模块。我需要安装google-cloud模块进行存储。

我使用的是 MacOS,我的环境统计数据:

  • npm v6.5.0

  • Node v10.0.0

这是我的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 google-cloud@0.58.2: 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

我使用了很多方法来安装该模块。但不行。

最佳答案

google-cloud 已弃用。不要使用它。

npm install --save @google-cloud/storage

其他 GCP 服务也有类似的软件包。

注意:在node.js SDK 2.x版本中,初始化SDK的方法发生了变化。

// 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,
});

关于node.js - Node.js 中的 Google-Cloud 模块安装失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54102192/

相关文章:

javascript - Later.js 每 5 个月重复一次规则

node.js - ENV 变量未正确添加到容器环境中

python - 在 Python 3 上向 App Engine 添加预热请求

javascript - Socket.io 从 Node 中的多个套接字接收数据

javascript - 可以从客户端 JavaScript 恢复上传吗?

express - 使用 Google Cloud Run 进行 SSL 客户端身份验证

javascript - 通过更好的排序加速 MongoDB find()? (使用 Mongoose orm)

node.js - 如何阻止 Azure DocumentDB 模拟器将 localhost 重定向到 HTTPS?

javascript - SSL23_GET_SERVER_HELLO :unknown protocol [connection to msa (587) port]

css - Angular 7 升级后样式问题