zip-it-and-ship-it: Strange bundling error when including sub directory
Including a file from a sub folder is crashing my netlify deploy with this error
. Hashing files...Error: Could not find "encoding" module in file: /unsubscribe-center/functions/redirect.js.
Please ensure "encoding" is installed in the project.
at handle (~/.nvm/versions/node/v10.4.1/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/finders.js:76:17)
at precinct.paperwork.forEach.dependency (~/.nvm/versions/node/v10.4.1/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/finders.js:102:11)
at Array.forEach (<anonymous>)
at getDependencies (~/.nvm/versions/node/v10.4.1/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/finders.js:95:8)
at filesForFunctionZip (~/.nvm/versions/node/v10.4.1/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/zip.js:65:7)
at zipJs (~/.nvm/versions/node/v10.4.1/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/zip.js:110:3)
at zipFunction (~/.nvm/versions/node/v10.4.1/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/zip.js:143:12)
at ~/.nvm/versions/node/v10.4.1/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/src/zip.js:181:9
at element (~/.nvm/versions/node/v10.4.1/lib/node_modules/netlify-cli/node_modules/p-all/index.js:4:67)
at Promise.resolve.then.element (~/.nvm/versions/node/v10.4.1/lib/node_modules/netlify-cli/node_modules/p-map/index.js:47:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! unsubscribe-center@0.1.0 deploy: `npm run build && netlify deploy -p`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the unsubscribe-center@0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/davidwells/.npm/_logs/2019-03-08T00_15_27_349Z-debug.log
The file is in a sub folder and has all the dependancies installed locally.

Here is the dep tree

I’m using node-fetch as a dependancy in the /functions/customerio/api/index.js file
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 20 (11 by maintainers)
Commits related to this issue
- Install 'encoding' as for Netlify error message. https://github.com/netlify/zip-it-and-ship-it/issues/16 — committed to marcomontalbano/video-to-markdown by marcomontalbano 5 years ago
- Add fix for encoding issue Suggested in https://github.com/netlify/zip-it-and-ship-it/issues/16 — committed to jayzces/website by deleted user 5 years ago
- chore: more deps fixes https://github.com/netlify/zip-it-and-ship-it/issues/16 — committed to yarnpkg/search-indexer-dashboard by Haroenv 5 years ago
- Add encoding as a dependency Workaround for node-fetch issue (https://github.com/netlify/zip-it-and-ship-it/issues/16) — committed to bengal75/hydro-tonight by deleted user 5 years ago
- Testing Netlify — committed to ramigs/netlify-lambda-github-webhook-router by ramigs 5 years ago
The solution is to install
encoding. Its an undeclared peer dependency of node-fetch. Our tree shaker may be a little to aggressive right now, but thats the solution for now.Just happened to me on a preview deployment with
node-fetchbeing a dependency of my lambda function.Thanks - ran into this issue. Resolved.
Since that’s a separate issue, I have opened a new issue at #66.
It looks like the original issue is solved. Please let me know if this appears again.
Also having this issue now, but it started from nothing, no change to netlify functions codebase whatsoever. In fact deploy previews were passing without issues and when it got merged to production, this poped up.