# NodeJS

Here's an example config for a NodeJS project.

workspace: true

stages:
- build-and-test

jobs:
  build:
    stage: build
    image: node:12-alpine
    script:
    - npm install
    - npm run lint
    - npm run build
    - npm run test

Though there's no additional benefit, if you prefer to have separate jobs for build & test, you can have something like this.

workspace: true

stages:
- build
- test

jobs:
  build:
    stage: build
    image: node:12-alpine
    script:
    - npm install
    - npm run build

  test:
    stage: test
    image: node:12-alpine
    script:
    - npm run lint
    - npm run test

If you prefer to use yarn, you can replace npm commands with yarn equivalent.