Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'long' import error #2111

Closed
chullino opened this issue May 3, 2022 · 6 comments · Fixed by #2112
Closed

'long' import error #2111

chullino opened this issue May 3, 2022 · 6 comments · Fixed by #2112

Comments

@chullino
Copy link

chullino commented May 3, 2022

Problem description

The latest version 0.6.10 has error with importing 'long', and as a result I can not compile. Error log comes like this.

node_modules/@grpc/proto-loader/build/src/index.d.ts:22:10 - error TS2617:  'Long' can only be imported by using 'import Long = require("long")' or by turning on the 'esModuleInterop' flag and using a default import.

22 export { Long } from 'long';

Reproduction steps

I can compile with dependency below.

    "@grpc/proto-loader": {
      "version": "0.6.9",
      "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.6.9.tgz",
      "integrity": "sha512-UlcCS8VbsU9d3XTXGiEVFonN7hXk+oMXZtoHHG2oSA1/GcDP1q6OUgs20PzHDGizzyi8ufGSUDlk3O2NyY7leg==",
      "requires": {
        "@types/long": "^4.0.1",
        "lodash.camelcase": "^4.3.0",
        "long": "^4.0.0",
        "protobufjs": "^6.10.0",
        "yargs": "^16.2.0"
      }
    },

I cannot compile with dependency below.

    "@grpc/proto-loader": {
      "version": "0.6.10",
      "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.6.10.tgz",
      "integrity": "sha512-TM2ghLt8pchK+XAlytMJ7RQvSqAb75c8kdizk6PuscNOT8aLYUL/CWESGLvp5GiDsWb6Gzs/VEen1M0e43ggZw==",
      "optional": true,
      "requires": {
        "@types/long": "^4.0.1",
        "lodash.camelcase": "^4.3.0",
        "long": "^5.2.0",
        "protobufjs": "^6.10.0",
        "yargs": "^16.2.0"
      }
    },

Environment

  • MacOS Big Sur
  • node version: 14.17.3
  • Node installation method : nvm

Additional context

I had been building without any problem until yesterday. The error came out today.

@murgatroid99
Copy link
Member

That's weird, because the only change in version 0.6.10 was to remove the line of code that appears in the quoted error message. Please double-check what version of the package is actually installed in that path.

@chullino
Copy link
Author

chullino commented May 3, 2022

IMHO, I don't think that's the only change because the dependency also changed.

"long": "^4.0.0" => "long": "^5.2.0"

I solved this problem by wiping out all the dependencies, installing @grpc/proto-loader@0.6.9.

rm -rf node_modules
rm package-lock.json
npm install @grpc/proto-loader@0.6.9
npm install

@denis-vogrincic
Copy link

This also breaks build where other packages have this as a dependency.

@lovell
Copy link

lovell commented May 3, 2022

There's an upstream issue at dcodeIO/long.js#109 that suggests upgrading long from v4 to v5 might be a breaking-breaking change for TypeScript users.

(This issue is affecting the downstream google-gax package and therefore much of the @google-cloud/... package ecosystem.)

@murgatroid99
Copy link
Member

Can someone please share the specific error that this causes? The quoted error message refers to a line that is not in version 0.6.10 of this package, and therefore it cannot possibly reflect a breakage in version 0.6.10 of the package.

@murgatroid99
Copy link
Member

This should be fixed in 0.6.11. If you have a dependency on long version 4, proto-loader will use it instead of installing long version 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants