Skip to content

Commit

Permalink
BUGFIX. Wrong 'node' and 'deploy' workflows when using node versions >14
Browse files Browse the repository at this point in the history
Error:
- In the `node` workflow, the `npm ci` command does not work, it needs the `package-lock.json` file to work, but this file is removed by the npm `preinstall` script.

Solution:
- Use in workflows the `npm install` command instead of `npm ci`. The `npm install` automatically runs the npm `preinstall` script which already does a clean install, removing the `node_modules` folder and the `package-lock.json` file.
- Use `node` version 14 for the project, the following versions still do not work.

References:
- npm-force-resolutions not working when installing a new package
https://stackoverflow.com/a/68095189/10855837
- What is the difference between "npm install" and "npm ci"?
https://stackoverflow.com/a/53325242/10855837
- Npm install fails in npm-force-resolutions if there is a space in the user folder
rogeriochaves/npm-force-resolutions#17
- NPM force-resolutions
https://www.npmjs.com/package/force-resolutions
  • Loading branch information
beatrizsmerino committed Jul 6, 2022
1 parent ee71d22 commit 8a75a8b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gh-pages-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
- name: Setup Node.js for use with actions
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 14.x

- name: Checkout branch
uses: actions/checkout@v3

- name: Clean install dependencies
run: npm ci
run: npm install

- name: Run deploy script
run: |
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ master ]
branches: [ "master" ]
pull_request:
branches: [ master ]
branches: [ "master" ]

jobs:
build:
Expand All @@ -16,14 +16,16 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [12.x, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test --if-present
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"nth-check": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.1.tgz"
},
"volta": {
"node": "16.15.1",
"node": "14.19.3",
"npm": "6.14.17"
}
}
}

0 comments on commit 8a75a8b

Please sign in to comment.