Google-api-nodejs-client: Error: No valid exports main found for '\node_modules\uuid'

Created on 9 May 2020  路  6Comments  路  Source: googleapis/google-api-nodejs-client

Environment details

  • OS: Windows 10
  • Node.js version: v13.2.0
  • npm version: 6.13.1
  • googleapis version: 50.0.0

Steps to reproduce

  1. const { google } = require('googleapis');

When trying to use the youtube upload sample, it throws this error:

Error: No valid exports main found for '\node_modules\uuid'
    at resolveExportsTarget (internal/modules/cjs/loader.js:611:9)
    at applyExports (internal/modules/cjs/loader.js:492:14)
    at resolveExports (internal/modules/cjs/loader.js:541:12)
    at Function.Module._findPath (internal/modules/cjs/loader.js:643:22)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:941:27)
    at Function.Module._load (internal/modules/cjs/loader.js:847:27)
    at Module.require (internal/modules/cjs/loader.js:1016:19)
    at require (internal/modules/cjs/helpers.js:69:18)
    at Object.<anonymous> (\node_modules\googleapis-common\build\src\apirequest.js:19:14)
    at Module._compile (internal/modules/cjs/loader.js:1121:30) {
  code: 'MODULE_NOT_FOUND'
}
needs more info question

Most helpful comment

Ah. uuid doesn't support node v13. https://github.com/uuidjs/uuid/issues/466#issuecomment-641129599

works fine on node 14.4.0. sgtm.

All 6 comments

Hi @bruxo00,

Would you mind including the code snippet which is failing? Just confirming, have you already installed googleapis before running the code sample?

Would you also mind trying running rm -rf node_modules package-lock.json && npm install to ensure the dependencies are up-to-date? Thanks in advance!

Hi @sofisl, thanks for the tips. I had already tried that, reinstalled everything multiple times. In my case, the steps to reproduce the issue are:

npm init
npm install --save googleapis

Then I import googleapis on my file

const { google } = require('googleapis');

Run the file

node app.js

And it throws the error.

Ok, just tried the same steps on my Linux machine and it works... Don't know if this is a specific problem of my computer or if it doesn't work in every Windows machine... Gonna try in my laptop that also has Windows installed and I'm gonna see if it does the same. Btw my Linux machine has:

Ubuntu 19.10
NodeJS v13.9.0
NPM 6.13.7

Tried on my laptop and it worked. Updated NodeJS on this machine to v14.2.0 and now it's working fine.

I can also reproduce this bug, with a slightly different error message, but the stack is otherwise the same.

Error: Package exports for './node_modules/uuid' do not define a valid '.' target

Node v13.1.0
mac os 10.14.6

my index.js and package.json:

const {google} = require('googleapis');
{
  "name": "cruxapinode",
  "main": "index.js",
  "dependencies": {
    "googleapis": "^52.1.0"
  }
}
node index.js

Ah. uuid doesn't support node v13. https://github.com/uuidjs/uuid/issues/466#issuecomment-641129599

works fine on node 14.4.0. sgtm.

Was this page helpful?
0 / 5 - 0 ratings