Strange bundling error when including sub directory
See original GitHub issueIncluding 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
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:20 (11 by maintainers)
Top Results From Across the Web
ASP.Net MVC 5 sub-directory bundling issues - Stack Overflow
I am seeing a weird behavior with bundling in my ASP.Net MVC 5 project. My project works just fine when I explicitly declare...
Read more >Failed to read the bundle file in … | Apple Developer Forums
This problem is a bit strange. I read a JS file from Bunlde and perform calculations. The following is part of the code,...
Read more >Building Asset Bundles weird problem ("Cannot create folder ...
I created smaller project and made few same named folders, assigned asset bundles and reproduced problem. Case is unknown, error not shows when ......
Read more >An elegant solution of deploying React app into a subdirectory
This is an alternative solution that will help you to deploy your react app into subfolder utilizing native html capabilities.
Read more >Code-splitting for libraries—bundling for npm with Rollup 1.0
This will keep the node_modules folder of your users small and make npm install faster. You could also create an .npmignore file for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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.