CMS Development

icheshire
Participant

Uploading node_modules

Hey, I found out today that I can't upload node_modules because it's blocked by hubspot. I get that node_modules isn't ideal, but how else am I supposed to keep track of dependencies? I don't think manually uploading every external dependency I need, or using a CDN, is a realistic solution because there's no way to manage and update my dependencies.

0 Upvotes
7 Replies 7
SKumar15
Participant | Elite Partner
Participant | Elite Partner

Uploading node_modules

Hello @icheshire , I am not exactly aware of your development workflow.

But in the case of design manager and custom code workflows and serverless functions, You have to generate a bundle file and upload it to the place where you need it. There's no direct way of uploading node_modules to hubspot cms because it is not meant for that.

Here is an example for custom code : https://developers.hubspot.com/blog/how-to-use-npm-packages-in-custom-code-workflow-actions

0 Upvotes
icheshire
Participant

Uploading node_modules

Isn't this for workflows, and not hubspot CMS?

0 Upvotes
SKumar15
Participant | Elite Partner
Participant | Elite Partner

Uploading node_modules

Yes, this is for workflows, but you have to do a similar thing for cms as well, compile the modules in a bundle, upload it to the design manager using cli or directly, and then import it in the module using require_js or use the bundle globally and use the require  function to get access to packages within the bundle.

0 Upvotes
alyssamwilie
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Uploading node_modules

You should really be using a source code repository like BitBucket or GitHub to store and track your files. The HubSpot Design Manager is not meant to be a respository, but a manager for compiled files only. Also, if you're not already using it, I suggest using the HubSpot CLI to upload your compiled files.

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
0 Upvotes
icheshire
Participant

Uploading node_modules

No, I wanted to use the files in node modules - node modules for frontend usually have a compiled `dist` folder. I know it's wasteful to upload the whole thing, but how else do I get tracked and organized dependencies for hubspot?

0 Upvotes
alyssamwilie
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Uploading node_modules

Files in node_modules should never be referenced directly in the project as that's not how pcakages are meant to be used. Ideally the files should be getting compiled into your own files using imports and/or a bundler. If you aren't comfortable with using bundlers and aren't using very many packages you could instead use CDN or copy/paste the dist files directly into your project. Also, due to it's normally large size, node_modules shouldn't ever be tracked but instead managed with a package manager.

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
0 Upvotes
icheshire
Participant

Uploading node_modules

But how would you do that using github / hubspot CMS?
0 Upvotes