googleapis / nodejs-storage

Node.js client for Google Cloud Storage: unified object storage for developers and enterprises, from live data serving to data analytics/ML to data archiving.
https://cloud.google.com/storage/
Apache License 2.0
898 stars 369 forks source link

calling new Storage() makes my app crashes with weird backtrace #1159

Closed sboudouk closed 4 years ago

sboudouk commented 4 years ago

Environment details

Steps to reproduce

I don't not know what causes this error so I am not able to create it again, even trying on a new created app, i can't reproduce, but i'm low-experienced so maybe you could help with this. I am also using TypeScript.

Here is the error I get , my application works fine but when I add const storage = new Storage(); I keep running into this:

graceful-fs.js:66 Uncaught TypeError: Cannot read property 'toString' of undefined
    at Object.<anonymous> (graceful-fs.js:66)
    at Object../node_modules/graceful-fs/graceful-fs.js (graceful-fs.js:258)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Object../node_modules/configstore/index.js (index.js:7)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Object.<anonymous> (index.js:24)
    at Object../node_modules/gcs-resumable-upload/build/src/index.js (index.js:467)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Object.<anonymous> (file.js:45)
    at Object../node_modules/@google-cloud/storage/build/src/file.js (file.js:3029)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Object.<anonymous> (bucket.js:45)
    at Object../node_modules/@google-cloud/storage/build/src/bucket.js (bucket.js:2828)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Object../node_modules/@google-cloud/storage/build/src/index.js (index.js:19)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Module../src/containers/documents/index.tsx (messages.ts:1)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Module../src/App.tsx (custom.scss:4)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Module../src/index.tsx (reason.tsx:32)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Object.0 (route.ts:20)
    at __webpack_require__ (bootstrap:781)
    at checkDeferredModules (bootstrap:45)
    at Array.webpackJsonpCallback [as push] (bootstrap:32)
    at main.chunk.js:1

Thanks for help.

laljikanjareeya commented 4 years ago

@sboudouk To better understand your problem could you provide the code snippet.

sboudouk commented 4 years ago

I am just calling

import { Storage } from @google-cloud/Storage

const bucket = new Storage();

Here are my package.json dependencies :


  "dependencies": {
    "@g07cha/flexbox-react": "^5.0.0",
    "@types/cordova": "0.0.34",
    "@types/iban": "0.0.30",
    "@types/jest": "24.0.16",
    "@types/lodash": "^4.14.149",
    "@types/node": "12.6.9",
    "@types/react": "16.8.24",
    "@types/react-dom": "16.8.5",
    "@types/react-router-dom": "^5.1.2",
    "@types/react-stripe-elements": "^1.3.4",
    "@types/styled-components": "^4.1.18",
    "@types/twilio-video": "^2.0.10",
    "@types/validator": "^10.11.3",
    "apisauce": "^1.1.0",
    "bootstrap": "^4.3.1",
    "formik": "^1.5.8",
    "iban": "0.0.14",
    "lodash": "^4.17.15",
    "react": "^16.8.6",
    "react-bootstrap": "^1.0.0-beta.10",
    "react-dom": "^16.8.6",
    "react-icons": "^3.8.0",
    "react-persist-hook": "^1.0.7",
    "react-router-dom": "^5.1.2",
    "react-scripts": "^3.4.1",
    "react-stripe-elements": "^5.0.1",
    "styled-components": "^4.3.2",
    "twilio-video": "^1.19.2",
    "typescript": "3.5.3",
   "validator": "^11.1.0",
jkwlui commented 4 years ago

I notice you're using webpack, unfortunately, this package only works on Node.js.