'Do I have to commit node_modules in order to run GitLab .gitlab-ci.yml builds?
Trying to create a .gitlab-ci.yml file to do builds in GitLab.
All attempts thus far fail.
Few examples I am able to find and those seem to have node_modules saved to the repository and use of Docker.
I've no knowledge about Docker.
Are Docker and storing node_modules required in order to perform builds on GitLab? (We don't store the node_modules)?
Here is the entirety of the script which is minimalist and does not work.
stages: # List of stages for jobs, and their order of execution
- build
build-job: # This job runs in the build stage, which runs first.
stage: build
script:
# - npm run build_def_fouo
- ng build -c def-fouo
- echo "Compiling the code..."
With npm I get: npm: command not found
With ng I get: ng: command not found
I'm at a loss.
===updated 05/06/2022
Made a little bit of progress this morning after 51 failed pipelines.
Here is my latest script but I'm reviewing the logs and will update with information to debug...
image: node:14.17.0
cache:
paths:
- node_modules/
stages: # List of stages for jobs, and their order of execution
- setup
- build
Test:
stage: setup
script:
- npm install # or `npm install` or whatever you use to install deps
Builder:
stage: build
script: # ... your other build steps here
- npm run build_def_fouo
=== Error Log
Error: node_modules/ng2-material-dropdown/src/modules/components/button/ng2-dropdown-button.d.ts:18:21 - error TS2694: Namespace '"/builds/elijah.d.j.marshall/ghostshot/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.
Solution 1:[1]
Generally, you would install your dependencies as part of your job. You could also form a custom docker image for building your software, but this is not necessary.
build-job:
stage: build
image: node:lts # this image includes npm/yarn/etc
# you can use different tags for different versions
script:
- yarn install # or `npm install` or whatever you use to install deps
# ... your other build steps here
You can find examples for nodejs and many other scenarios in the examples documentation.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | sytech |