【问题标题】:Google Cloud: Create A Simple Application With the API samples npm install failedGoogle Cloud:使用 API 示例创建一个简单的应用程序 npm install failed
【发布时间】:2018-04-27 20:11:13
【问题描述】:

按照这里的说明,https://cloud.google.com/bigquery/create-simple-app-api

cd 到示例文件夹

https://github.com/googleapis/nodejs-bigquery/tree/master/samples

package.json 是

https://github.com/googleapis/nodejs-bigquery/blob/master/samples/package.json

{
  "name": "nodejs-docs-samples-bigquery",
  "version": "0.0.1",
  "private": true,
  "license": "Apache-2.0",
  "author": "Google LLC",
  "repository": "googleapis/nodejs-bigquery",
  "engines": {
    "node": ">=4"
  },
  "scripts": {
    "test": "repo-tools test run --cmd npm -- run cover",
    "ava": "ava -T 3m --verbose test/*.test.js system-test/*.test.js",
    "cover": "nyc --reporter=lcov --cache ava -T 3m --verbose test/*.test.js system-test/*.test.js && nyc report"
  },
  "dependencies": {
    "@google-cloud/bigquery": "1.2.0",
    "@google-cloud/storage": "1.5.1",
    "yargs": "10.0.3"
  },
  "devDependencies": {
    "@google-cloud/nodejs-repo-tools": "2.1.3",
    "ava": "0.24.0",
    "nyc": "11.3.0",
    "proxyquire": "1.8.0",
    "sinon": "4.1.3",
    "uuid": "3.1.0"
  }
}

我跑

npm install

我收到错误

    Home-iMac:samples user1$ npm install
    npm WARN @google-cloud/bigquery@1.2.0 had bundled packages that do not match the required version(s). They have been replaced with non-bundled versions.

    npm ERR! path /Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/@google-cloud/bigquery-78ee5bef/node_modules/@sindresorhus/is
    npm ERR! code ENOENT
    npm ERR! errno -2
    npm ERR! syscall rename
    npm ERR! enoent ENOENT: no such file or directory, rename '/Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/@google-cloud/bigquery-78ee5bef/node_modules/@sindresorhus/is' -> '/Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/@sindresorhus/is-79439449'
    npm ERR! enoent This is related to npm not being able to find a file.
    npm ERR! enoent 

    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/user1/.npm/_logs/2018-04-27T19_38_14_391Z-debug.log

要修复错误,hack 解决方案不是使用 package.json 来安装,我必须先手动运行它

npm install --save @google-cloud/bigquery

那我可以跑了

npm install

再次。这一次,它会顺利完成。

但我希望能够仅使用 package.json,仅使用 npm install 来安装包。

我更改了 package.json 从 "@google-cloud/bigquery": "1.2.0", 到 "@google-cloud/bigquery": "^1.2.0",

还是不行。

谢谢!

【问题讨论】:

  • 感谢您的报告。我相信您遇到了这个问题,因为该示例被配置为使用 GitHub 上的库版本,而不是发布的版本。我将要求更新示例。

标签: node.js google-api google-cloud-platform google-bigquery


【解决方案1】:

@Tim - 感谢更新请求,@google/bigquery 1.3.0 用于示例。 GitHub 站点的下载链接已更新,但页面本身的示例代码未更新。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-15
    • 2017-11-14
    • 1970-01-01
    相关资源
    最近更新 更多