cloud-profiler-nodejs icon indicating copy to clipboard operation
cloud-profiler-nodejs copied to clipboard

Doesn't install on machines using Python 3.12

Open somewhatabstract opened this issue 2 years ago • 0 comments

The version of node-gyp doesn't support Python 3.12. Note that just updating to v10 brings in a new version of string-width that is ESM only and causes a different issue during pprof building, depending on other dependencies.

Environment details

  • OS: Ubuntu 22.04.3
  • Node.js version: 20.10.0
  • npm version: 10.2.5
  • @google-cloud/profiler version: 6.0.0

Steps to reproduce

  1. Use Python 3.12 (this is default in the Ubuntu 22.04.3 GitHub Actions OS image)
  2. Install @google-cloud/profiler
  3. [Problem ->] See error about missing module (this is due to it being removed in Python 3.12 release)
  4. Pin to node-gyp 10
  5. [Subsequent problem ->] Things should work - however, some code then has conflicts on the version of the string-width module and so errors like this can appear:
  khan/wonder-stuff/node_modules/wide-align/align.js:2
var stringWidth = require('string-width')
                  ^

Error [ERR_REQUIRE_ESM]: require() of ES Module khan/wonder-stuff/node_modules/string-width/index.js from khan/wonder-stuff/node_modules/wide-align/align.js not supported.
Instead change the require of index.js in khan/wonder-stuff/node_modules/wide-align/align.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (khan/wonder-stuff/node_modules/wide-align/align.js:2:19) {
  code: 'ERR_REQUIRE_ESM'

I have managed to get something working by pinning node-gyp to v10 and then pinning string-width to v4, but that's not a viable long term solution.

somewhatabstract avatar Dec 15 '23 18:12 somewhatabstract