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 7, 2022
1 parent 5b57eb2 commit 1f6a2bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [14.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm install
- run: npm run build --if-present
- run: npm test --if-present
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"install:clean": "rm -rf node_modules package-lock.json",
"preinstall": "npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions",
"preinstall": "npm run install:clean && npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions",
"deploy": "chmod +x ./deploy.sh && ./deploy.sh"
},
"author": "[email protected]",
Expand Down

0 comments on commit 1f6a2bd

Please sign in to comment.