Unable to deploy; Error while deploying functions
bestpricedin opened this issue · comments
Hi,
I forked a repo at https://github.com/bestpricedin/create-react-app-lambda, changed babel-loader
version as "babel-loader": "8.0.5"
, using yarn.
I am using netlify-cli
to run this locally and it works.
When I deploy to netlify, I get following error. Can you please help me solve the error?
My netlify -v
is netlify-cli/2.11.14 darwin-x64 node-v8.15.0
12:55:51 PM: Starting to prepare functions from 'build'
12:55:51 PM: Zipping functions from /opt/build/repo/built-lambda to /tmp/zisi-889841717
12:55:52 PM: Error: Could not find "encoding" module in file: /repo/built-lambda/async-dadjoke.js.
Please ensure "encoding" is installed in the project.
12:55:52 PM: Failing build: Failed to prepare functions for deployment
12:55:52 PM: failed during stage 'preparing functions for deployment': exit status 1
12:55:52 PM: Finished processing build request in 54.037857466s
12:55:52 PM: Shutting down logging, 0 messages pending
I was able to solve this by installing encoding
as dependency.
node-fetch
has a hidden dependency on encoding
. very annoying.
we will switch to axios someday. pr welcome
I ran into this issue just now as well, trying to deploy this repo directly after cloning.
I cloned this repo months ago, same node-fetch version("2.3.0"), and it deployed with no issues, so I'm not sure I understand what changed. I also solved it by adding encoding
as a dependency.
Is everyone having this error?
@sw-yx
Do you think the encoding
package should just be included in repo itself for now? Or it's just a few people with this issue?
5:16:44 PM: Function Dir: /opt/build/repo/built-lambda
5:16:44 PM: TempDir: /tmp/zisi-828681410
5:16:45 PM: Prepping functions with zip-it-and-ship-it 0.3.1
5:16:46 PM: Error: Could not find "encoding" module in file: /repo/built-lambda/async-dadjoke.js.
5:16:46 PM: Please ensure "encoding" is installed in the project.
5:16:46 PM: Error prepping functions
5:16:46 PM: Error running command: Build script returned non-zero exit code: 1
5:16:46 PM: Failing build: Failed to build site
5:16:46 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
5:16:46 PM: Finished processing build request in 1m5.445676244s
5:16:46 PM: Shutting down logging, 0 messages pending
i'm not sure to be honest. it does sound like this issue appears irregularly. the node-fetch team buried it deep in their docs: node-fetch/node-fetch#412 (comment)
tbh i would rather just switch to axios. dont want to be blamed for node-fetch's problems.