question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Strange bundling error when including sub directory

See original GitHub issue

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.

image

Here is the dep tree

image

I’m using node-fetch as a dependancy in the /functions/customerio/api/index.js file

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

10reactions
bcomnescommented, Apr 18, 2019

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.

3reactions
polarbirkecommented, Oct 24, 2019

Just happened to me on a preview deployment with node-fetch being a dependency of my lambda function.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found