After I read this and many other github issue and stackoverflow, didn’t find way to resolve it.
Error: EACCES: permission denied
I also read and tried this one as well,
How to fix EACCES issues with npm install
but the docker does not have sudo
command and I tried whoami
and it says “root” which means I already running with root privilege.
I have a action stage like this.
build-frontend:
stage: build
image: node:18-alpine
script:
- npm -v
# create a user for the frontend build
- cd frontend
- npm i -g --unsafe-perm=true --allow-root
- npm run build
- echo "Build complete, check if backend has newest frontend changes"
- git diff --exit-code
But the action log give give me this
$ npm i --unsafe-perm=true --allow-root
npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/object-schema instead
npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/config-array instead
npm warn deprecated [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
npm error code 1
npm error path /builds/***/****/****/node_modules/esbuild
npm error command failed
npm error command sh -c node install.js
npm error node:internal/errors:496
npm error ErrorCaptureStackTrace(err);
npm error ^
npm error
npm error <ref *1> Error: spawnSync /builds/****/****/*****/node_modules/esbuild/bin/esbuild EACCES
npm error at Object.spawnSync (node:internal/child_process:1117:20)
npm error at spawnSync (node:child_process:876:24)
npm error at Object.execFileSync (node:child_process:919:15)
npm error at validateBinaryVersion (/builds/****/****/******/node_modules/esbuild/install.js:99:28)
npm error at /builds/****/*****/*****/node_modules/esbuild/install.js:283:5 {
npm error errno: -13,
npm error code: 'EACCES',
npm error syscall: 'spawnSync /builds/*****/*****/*****/node_modules/esbuild/bin/esbuild',
npm error path: '/builds/*****/*****/******/node_modules/esbuild/bin/esbuild',
npm error spawnargs: [ '--version' ],
npm error error: [Circular *1],
npm error status: null,
npm error signal: null,
npm error output: null,
npm error pid: 0,
npm error stdout: null,
npm error stderr: null
npm error }
npm error
npm error Node.js v18.20.5
npm error A complete log of this run can be found in: /root/.npm/_logs/2024-11-18T23_38_00_917Z-debug-0.log
I have tried multiple version of node including latest, 20, 18, and much more.
I have, of course, tried simply use npm install
to install all the dependecy, but it return the same error.
I have spent whole days in to this error, reading countless of postes relate to this issue but none of these post are like my issue. Most of the post I have read is about root prilivege, but the docker default use is root, and I check it with whoami
. I tired to execute the npm install
with su root -c
, run chown
, and none of these work.
I tried npm -g install
but in the later stage, npm run build
does not work saying that vite not found
so I think I have to install the package locally.
I can run npm install
on my local Windows machine but somehow not on the gitlab action.
I believe the warning can be ignored because I saw the same warning when running npm install
and still file.
I also upgrade all the depencency, so no more warning but error still remains.
I really haw no idea about this issue. I have done many node project and set up ci cd, but it is the first I see it.
This the the package.json file
{
"name": "frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite --mode development",
"build": "vite build --mode production --emptyOutDir",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.40.1",
"@vitejs/plugin-basic-ssl": "^1.1.0",
"antd": "^5.19.0",
"net-hr-contactinfo-frontend": "file:",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.23.1"
},
"devDependencies": {
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.57.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"sass": "^1.77.4",
"vite": "^5.2.0"
}
}