admin管理员组

文章数量:1404329

I have updated a Meteor Project to 3.1.2 which has broken the @google-cloud/storage package. Just importing the @google-cloud/storage package gives the following error.

Uncaught TypeError: Cannot read properties of undefined (reading 'isTTY')

I've determined that it has somehting to do with readStream. But i can not for the life of me figure out if its a problem with meteor, a problem with node, or a problem with @google-cloud/storage. Has anyone else had this problem?

Packages is @google-cloud/[email protected]

Package runs on Meteor version 2.14, node version 14.21.3 Package broken on Meteor version 3.1.2 node version 22.13.1

Minimum Reproducable example

create a new meteor project @3.1.2 using the following command

meteor create <PROJECT NAME> --release 3.1.2

(You can just create without defining version as 3.1.2 is currently latest but just being specific)

navigate to project folder. install @google-cloud/storage using the following command

meteor npm install @google-cloud/[email protected]

(you can just install newest @google-cloud/storage but i know 7.14.0 works on the previous version of meteor)

import @google-cloud/storage in any api using the following code

import { Storage } from '@google-cloud/storage';

Run the meteor project. It will run but if you try to access it at localhost:3000 it will crash and give the following error message in the dev console.

Uncaught TypeError: Cannot read properties of undefined (reading 'isTTY')

I have updated a Meteor Project to 3.1.2 which has broken the @google-cloud/storage package. Just importing the @google-cloud/storage package gives the following error.

Uncaught TypeError: Cannot read properties of undefined (reading 'isTTY')

I've determined that it has somehting to do with readStream. But i can not for the life of me figure out if its a problem with meteor, a problem with node, or a problem with @google-cloud/storage. Has anyone else had this problem?

Packages is @google-cloud/[email protected]

Package runs on Meteor version 2.14, node version 14.21.3 Package broken on Meteor version 3.1.2 node version 22.13.1

Minimum Reproducable example

create a new meteor project @3.1.2 using the following command

meteor create <PROJECT NAME> --release 3.1.2

(You can just create without defining version as 3.1.2 is currently latest but just being specific)

navigate to project folder. install @google-cloud/storage using the following command

meteor npm install @google-cloud/[email protected]

(you can just install newest @google-cloud/storage but i know 7.14.0 works on the previous version of meteor)

import @google-cloud/storage in any api using the following code

import { Storage } from '@google-cloud/storage';

Run the meteor project. It will run but if you try to access it at localhost:3000 it will crash and give the following error message in the dev console.

Uncaught TypeError: Cannot read properties of undefined (reading 'isTTY')
Share Improve this question edited Mar 11 at 21:53 Alexander Mason asked Mar 11 at 11:40 Alexander MasonAlexander Mason 211 silver badge4 bronze badges 3
  • It's hard to say from this. Have you been able to produce a minimal reproducible example? If it's just he import of @google-cloud/storage then it should be very easy to create such an example. Have you tested that? – Christian Fritz Commented Mar 11 at 15:52
  • Minimum Reproducible example. create a new meteor project @3.1.2. install @google-cloud/storage. import @google-cloud/storage to an api. The meteor create command makes a simple api called links.js you can import there. Im currently trying playing around in a default project. – Alexander Mason Commented Mar 11 at 21:32
  • Have added mimimum reproducable example to the question and removed eronious code. – Alexander Mason Commented Mar 11 at 21:44
Add a comment  | 

1 Answer 1

Reset to default 1

I figured out what was going on. This was a client side simulation problem. If your code is loaded on the client side you can no longer do the following to import the module.

import { Storage } from '@google-cloud/storage';

export default async function(<DATA>) {
    if(Meteor.isServer) {
        <DO STUFF>
    }
}

Instead you must do the following.

export default async function(<DATA>) {
    if(Meteor.isServer) {
        const { Storage } = require('@google-cloud/storage');
        <DO STUFF>
    }
}

I have no idea why this is different now, it has nothing to do with meteor, node, or @google-cloud/storage versions. Older projects allow me to do the first, newer project need me to do the second.

本文标签: nodejsUncaught TypeError Cannot read properties of undefined (reading 39isTTY39)Stack Overflow