Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

CI/CD Is it possible to use node_modules folder pushed in repository?

Costantino Carta
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 2, 2023

Hello everyone, 

I'm trying to build a pipeline to deploy my angular14 app into a private server.

I'm facing this issue:

as we've built a custom angular material theme in our app we have changed some files within 'node_modules' folder.

Within the styles.css file there are references at that particular theme defined in a file within angular material folder in node_modules.

I can't run 'npm install' command in my pipeline as we lose the definition of our custom theme and we get an error in the building phase caused by the references defined in 'styles.css' file.

Is there a way to push my 'node_modules' folder within the docker container within the pipeline instead of installing the dependencies from 'package.json'?

The 'caching' solution seems to not be helpful to this particular case..

Does anyone have a solution?

Thanks in advance,

Costantino.

1 answer

1 accepted

0 votes
Answer accepted
Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2023

From Docker perspective, `node_modules` is just another folder and you can COPY it like any other file/folder.

You should note that:

  1. The folder should exists within the docker context in order to be copied. 
  2. The folder is not excluded using the .dockerignore file.
  3.  Some dependencies have different OS variations, IE: the dependency for MacOS is different from the Linux one.   

Last point & personal recommendation - Coping the node_module is not stand procedure and may lead to unexpected results. Do revise your process. It might be a bit safer to first install the mode module you want to override its CSS, override the CSS files and then install the rest of the dependencies. Something like this:
npm install module
cp new_file.css node_module/module/old_file.css
npm install   

Hope that helps

Costantino Carta
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 3, 2023

HI Erez, 

thank you so much for your response!

I will follow your suggestion avoiding to copy all the node_modules folder.

I'm gonna try replace the files I need. I want to ask, how can I put my files in the docker container through the bitbucket pipeline? Sorry but I am a newbie using docker.

Thanks in advance

Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2023

Hey @Costantino Carta 

Usually, you first clone your project which brings all your files.

Then, If you run your docker command from the root folder, all files will be included by default. 

If your code base includes multiple projects, you might have to pass the correct Dockerfile and context to the docker command.

This might help: https://docs.docker.com/engine/reference/commandline/build/

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events