【问题标题】:Google-Cloud module install fail in node.jsnode.js 中的 Google-Cloud 模块安装失败
【发布时间】:2019-06-03 18:13:07
【问题描述】:

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

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

  • npm v6.5.0

  • 节点 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
纱线添加 v1.6.0
(节点:81069)[DEP0005] DeprecationWarning:由于安全性和可用性问题,不推荐使用 Buffer()。请改用 Buffer.alloc()、Buffer.allocUnsafe() 或 Buffer.from() 方法。
[1/4] ????正在解析包...
警告 google-cloud@0.58.2: google-cloud 包已被弃用。我们强烈建议安装单独的 API 包,例如 @google-cloud/storage。有关 Google Cloud Platform API 特定包的列表,请访问
https://cloud.google.com/nodejs/docs/reference/libraries
[2/4] ????正在获取包...
[3/4] ????链接依赖项...
[4/4] ????构建新的包...
[1/1] ⠂ 谷歌云
[-/1] ⠂ 等待...
[-/1] ⠂ 等待...
[-/1] ⠂ 等待...
错误 /Users/manlokwong/Desktop/BeastQuestServer/bq_server/node_modules/google-cloud:命令失败。
退出代码:255
命令:节点脚本/preinstall.js
参数:
目录:
/Users/manlokwong/Desktop/BeastQuestServer/bq_server/node_modules/google-cloud

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

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-19
      • 2013-11-04
      • 2020-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多