question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not resolve "../package.json" on v5.20.1

See original GitHub issue

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

  1. Is this a client library issue or a product issue? library issue

  2. Did someone already solve this? Not that I can find

  3. Do you have a support contract? No

Environment details

  • OS: macOS
  • Node.js version: 14 and 16
  • npm version: 6.14.16 and 8.5.5
  • @google-cloud/storage version: v5.20.1

Steps to reproduce

  1. Install @google-cloud/storage and use it as a dependency in your project
  2. Package your project with esbuild
  3. See that it fails with the following errors:
✘ [ERROR] Could not resolve "../package.json"

    node_modules/@google-cloud/storage/build/src/storage.js:384:34:
      384 │             packageJson = require('../package.json');
          ╵                                   ~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "../../package.json"

    node_modules/@google-cloud/storage/build/src/nodejs-common/util.js:37:26:
      37 │     packageJson = require('../../package.json');
         ╵                           ~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "../package.json"

    node_modules/@google-cloud/storage/build/src/gcs-resumable-upload.js:37:26:
      37 │     packageJson = require('../package.json');
         ╵                           ~~~~~~~~~~~~~~~~~

I am using firebase-admin which has @google-cloud/storage as a dependency. When I pin @google-cloud/storage to 5.19.4 I can package my app fine with esbuild. When it is updated to v5.20.1 it starts to fail with the above error.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ddelgrosso1commented, May 18, 2022

After investigating the issue was the result of a change we made to support running unit tests directly in TypeScript. This caused us to move to dynamic requires for package.json. This caused esbuild to not be able to analyze / inline the package.json any more. We have reverted the change and gone back to a single require call that should again allow esbuild to inline the file. This will be released with 5.20.4. I am going to leave this issue open in the meantime.

1reaction
ddelgrosso1commented, May 17, 2022

Thanks @timdp digging deeper into why this may be causing esbuild problems.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not resolve 'package.json' #15 - GitHub
The package.json file will be included in the bundle, but it is tree-shaken and inlined, so it should only include the "version" property...
Read more >
npm WARN npm npm does not support Node.js v9.1.0
It turns out that the current installed npm is not compatible with the new node and has a hard time updating. The solution...
Read more >
package.json - npm Docs
Trying to install another plugin with a conflicting requirement may cause an error if the tree cannot be resolved correctly. For this reason,...
Read more >
Node.js - CloudBees Documentation
CodeShip uses nvm to manage different Node.js versions. ... If the version is not specified in package.json or if your project does not...
Read more >
Preferred versions - Rush.js
But the common/temp/package.json described above would not guarantee this. ... ://developer.microsoft.com/json-schemas/rush/v5/common-versions.schema.json",
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found