I am getting error just after importing @google-cloud/storage : Module not found: Error can't resolve 'child_process', how to fix?
See original GitHub issueI am getting error just after importing @google-cloud/storage
Environment details
- OS: macOS Big Sur
- Node.js version: v12.18.4
- npm version:6.14.6
@google-cloud/storage
version:^ 5.6.0- framework nuxt js version : Nuxt.js @ v2.14.7
Steps to reproduce
- install @google-cloud/storage
yarn add @google-cloud/storage
ornpm install @google-cloud/storage --save
- import it const {Storage} = require(‘@google-cloud/storage’); const storage = new Storage({ keyFilename : path.join(__dirname, ‘./file.json’), projectId: “xxx-xxx-xxx” });
just after that i got this error
ERROR in ./node_modules/google-auth-library/build/src/auth/googleauth.js Module not found: Error: Can't resolve 'child_process' in '/Users/xxx/xxxx/node_modules/google-auth-library/build/src/auth' ERROR in ./node_modules/@google-cloud/storage/build/src/file.js Module not found: Error: Can't resolve 'fs' in '/Users/xxx/xxxx/node_modules/@google-cloud/storage/build/src' ERROR in ./node_modules/@google-cloud/storage/build/src/bucket.js Module not found: Error: Can't resolve 'fs' in '/Users/xxx/xxxx/node_modules/@google-cloud/storage/build/src' ERROR in ./node_modules/configstore/node_modules/make-dir/index.js Module not found: Error: Can't resolve 'fs' in '/Users/xxx/xxxx/node_modules/configstore/node_modules/make-dir' ERROR in ./node_modules/google-auth-library/build/src/auth/googleauth.js Module not found: Error: Can't resolve 'fs' in '/Users/xxx/xxxx/node_modules/google-auth-library/build/src/auth' ERROR in ./node_modules/google-p12-pem/build/src/index.js Module not found: Error: Can't resolve 'fs' in '/Users/xxx/xxxx/node_modules/google-p12-pem/build/src' ERROR in ./node_modules/graceful-fs/graceful-fs.js Module not found: Error: Can't resolve 'fs' in '/Users/xxx/xxxx/node_modules/graceful-fs' ERROR in ./node_modules/gtoken/build/src/index.js Module not found: Error: Can't resolve 'fs' in '/Users/xxx/xxxx/node_modules/gtoken/build/src' ERROR in ./node_modules/write-file-atomic/index.js Module not found: Error: Can't resolve 'fs' in '/Users/xxx/xxxx/node_modules/write-file-atomic' ERROR in ./node_modules/http-proxy-agent/dist/agent.js Module not found: Error: Can't resolve 'net' in '/Users/xxx/xxxx/node_modules/http-proxy-agent/dist' ERROR in ./node_modules/https-proxy-agent/dist/agent.js Module not found: Error: Can't resolve 'net' in '/Users/xxx/xxxx/node_modules/https-proxy-agent/dist' ERROR in ./node_modules/http-proxy-agent/dist/agent.js Module not found: Error: Can't resolve 'tls' in '/Users/xxx/xxxx/node_modules/http-proxy-agent/dist' ERROR in ./node_modules/https-proxy-agent/dist/agent.js Module not found: Error: Can't resolve 'tls' in '/Users/xxx/xxxx/node_modules/https-proxy-agent/dist'
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
This sounds like a fun thing with Nuxt that wants to use Webpack bundle even when running on the server side. I found https://github.com/nuxt-community/dotenv-module/issues/11 which suggested that we could blocklist some Node modules for webpack, and they will magically start working on the Node side of the things. Try this in your
nuxt.config.js
:My
pages/index.vue
that worked:Note: we have never tested this library with Nuxt. Consider this to be a “warranty void if seal broken” situation - let us know if anything does not work but fixing stuff might be complicated.
I’m having the same problem