6

I want to deploy an app without having to bundle all the node_modules in the folder.

So instead of having this folder deployed:

  • app.js
  • node_modules (big folder)

To have something like:

  • app.js
  • binary_dependencies

In the binary_dependencies should only include the binaries that can't be included in the app.js file.

The reason is because yarn install will create a big layer (500MB) in docker and is slow to upload. I wanted to reduce that size.

2
  • you can ignore node_modules and run npm install on server to download those dependencies. Commented Aug 20, 2018 at 6:39
  • So how does the bundled js file get access to the binary node_modules that are not in the bundled js file? Commented Aug 20, 2018 at 7:10

2 Answers 2

1

In my case, I did not have any "binary_dependencies" - all provided modules were bundled in "app.js". However, at first I had to disable webpack-node-externals as it purposely excluded some of the modules from my bundled "app.js". After disabling the module, I had to have only "Node" and app.js" on my docker container. By running "node app.js" I was able to start my "express.js" server without having to provide "node_modules" as they were already bundled inside my "app.js".

Sign up to request clarification or add additional context in comments.

Comments

0

upload the code with the file package.json, then cd to folder and run npm install Pay attention to the version you are installing suppose you have the following:

"dependencies": { "bluebird": "^3.5.1", "body-parser": "^1.18.3" } 

change it to:

"dependencies": { "bluebird": "3.5.1", "body-parser": "1.18.3" } 

1 Comment

Thanks, but your solution still has node_modules folder. I was asking how to bundle the node_modules in the bundles output file from webpack instead and only keep binary modules that can't be bundled in js code separate.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.