googleapis version: 39.2.0yarn add --exact googleapisconst { google } = require('googleapis')
Error: Cannot find module './docs'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/.../node_modules/googleapis/build/src/apis/index.js:77:14)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
Seconded. Node version v10.15.0, googleapis version 39.2.0
const { google } = require('googleapis')
const people = google.people('v1')
The error is thrown on build. If you comment out the second line, where we get the people api, the build error goes away. Also tried installing googleapis version 38.0.0 and still got the error.
Looks like pinning "googleapis": "37.0.0" will solve this issue, as long as you don't depend on the changes from the last couple of versions.
@kilianc did 37.0.0 unblock you?
"googleapis": "37.0.0" works for me
I'm going to close this out for now. Please do let us know if you're still having problems!
I upgrade on version "googleapis": "^40.0.0" and i have still the same error ๐ค
I downgrade "googleapis": "37.0.0" to do my job
@aDEVE would you be able to provide a GitHub repository with a minimum reproduction of this bug?
Weird, I'm unable to reproduce this. Very specific steps for me, running OSX:
$ node -v
v11.15.0
$ yarn -v
1.16.0
$ yarn add --exact googleapis
yarn add v1.16.0
[1/4] ๐ Resolving packages...
[2/4] ๐ Fetching packages...
[3/4] ๐ Linking dependencies...
[4/4] ๐จ Building fresh packages...
success Saved 1 new dependency.
info Direct dependencies
โโ [email protected]
info All dependencies
โโ [email protected]
โจ Done in 0.47s.
$ cat server.js
const {google} = require('googleapis');
const people = google.people('v1')
console.log(people);
$ yarn start
yarn run v1.16.0
$ node server.js
People {
context:
{ _options: {},
...
Can you share:
This bug is relative to the .yarnclean file. This file is provided by Yarn to automatically remove useless files inside node_modules directory. By default, yarn autoclean --init generates a .yarnclean file that exclude docs directories:
# asset directories
docs
doc
website
images
assets
To reproduce the problem:
yarn init --yes
yarn install
yarn autoclean --init
yarn add googleapis
node -e 'require("googleapis");'
# > Cannot find module './docs'
A very simple solution is to add an exception inside the .yarnclean file before installing googleapis package:
# asset directories
docs
!googleapis/build/src/apis/docs
But, without this change, yarn autoclean --init isn't compatible with googleapis...
The docs directory has been added in v37.2.0. So, this error only appears after v37.0.0.
Unless others have an idea of how to reasonably fix this on our side, I sadly think I need to close this out. The name docs and the accompanying directory is pretty key to the Google Docs product, and not something I think we can easily change. If others can think of something we could do - I would be more than happy to help!
I find it a little alarming that yarn would set a default like this that's potentially destructive. @bcoe you know anyone over on that side of the world?
Most helpful comment
This bug is relative to the
.yarncleanfile. This file is provided by Yarn to automatically remove useless files inside node_modules directory. By default,yarn autoclean --initgenerates a.yarncleanfile that excludedocsdirectories:To reproduce the problem:
A very simple solution is to add an exception inside the
.yarncleanfile before installing googleapis package:But, without this change,
yarn autoclean --initisn't compatible with googleapis...The
docsdirectory has been added in v37.2.0. So, this error only appears afterv37.0.0.