gax-nodejs: (Reopen PLEASE) Missing dependency `request` causes an error when using Google Cloud's Vision API
Environment details
- OS: Ubuntu 20.04 x64
- Node.js version: v14.2.0
- npm version: 7.24.1
google-gaxversion: 2.28.0
Steps to reproduce
- Create a
serverlessNode.js project - Add the
serverless-webpackplugin to yourserverless.ymlfile and usewebpackwithbabelto package the function that will be created - Add
@google-cloud/visionas a dependency - Create a Node.js Google Function or AWS Lambda that makes use of the Google Vision API (e.g. do something similar to what is shown in this SafeSearch example)
- Attempt to build the lambda with webpack
Error
WARNING in ./node_modules/retry-request/index.js 74:21-39
Module not found: Error: Can't resolve 'request' in '/home/user/project/node_modules/retry-request'
@ ./node_modules/@google-cloud/vision/node_modules/google-gax/build/src/streamingCalls/streaming.js 22:21-45
@ ./node_modules/@google-cloud/vision/node_modules/google-gax/build/src/index.js 64:18-55
@ ./node_modules/@google-cloud/vision/build/src/helpers.js 24:12-33
@ ./node_modules/@google-cloud/vision/build/src/index.js 31:16-36
@ ./src/image-service/handler/lambdaGcloudWorker.js 38:15-46
Possible solution
Add the package request as a dependency of the project here given you’ve included retry-request
Workaround
Add request as a dependency of the serverless project by running npm install request --save
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 16 (5 by maintainers)
Looking at this issue, I guess that we can come here every year and celebrate
google-gaxusing deprecated dependency. This year marks 4threquestdeprecation anniversary 🥳This still seems to be an issue for any
google-gaxmodule usingrequestwhich is depricated since 2020. npm request.Why this is closed? request is deprecated for 4 years now btw
Bump should we create a new issue to reopen this one?
@summer-ji-eng I think this should be re-opened. I don’t think it is just the OP’s serverless setup because I am hitting it using only Google stuff + webpack (and I don’t think webpack is at fault). To me it looks like google-gax did not install the parallel dependency of
retry-requestknown asrequest(as shown on the npm page for retry-request). I am hitting this when adding webpack to firebase functions, i.e. right afterfirebase init functions, choosing typescript, and using the built-in hello world example.Commands:
firebase init funcitonschoose typescript project and go into the functions directory Do basic installs:npm i --save-dev webpack webpack-cli ts-loaderRunnpx webpackand get the following:Running
npm i requestmakes this go away.Also bumping this to be reopened please. Should just be using
fetchin this day and ageDeployment with Cloudflare pages is also impacted.
still an issue
@tferrerm have you tried on the links I shared before? It is not gax issue, I assume that it is the
serverlessorwebpackdependency config issue.Is there any fix for it?