Problems Upgrading Strapi to Major Version with esbuild Module Not Found

Hey everyone, I’m trying to upgrade my Strapi project to the latest major version using the @strapi/upgrade command, but I keep running into issues related to esbuild not being found and permission errors. I’ve outlined below everything I’ve done so far, including the exact errors I’ve been getting.

I started by running the following command to install esbuild as a dev dependency:

npm install esbuild --save-dev

Result:

Installation completed successfully, but I got a message about vulnerabilities:

23 vulnerabilities (7 low, 12 moderate, 4 high)
To address all issues (including breaking changes), run:
npm audit fix --force

Then, I tried running the Strapi upgrade command:

npx @strapi/upgrade major

Error Message:

npm error code EACCES
npm error syscall open
npm error path /Users/dot/.npm/_cacache/index-v5/b9/1e/012cd3f5bc673c8fa91c2f64881687f5c31888b243179e4bc5435af5d387
npm error errno EACCES
npm error
npm error Your cache folder contains root-owned files, due to a bug in
npm error previous versions of npm which has since been addressed.
npm error
npm error To permanently fix this problem, please run:
npm error   sudo chown -R 501:20 "/Users/dot/.npm"

It suggested using sudo chown, but I wanted to try the next step before doing that.

After that error, I ran:

sudo npx @strapi/upgrade major

Error Message:

node:internal/modules/cjs/loader:1143
  throw err;
  ^

Error: Cannot find module 'esbuild'

Additional Details:

  • Node version: 18.20.4
  • I have tried running the npm audit fix --force, but I was hesitant since it warned about breaking changes.
  • The esbuild module is installed, and I verified that esbuild is listed as a dependency in my package.json.
  • The permission issue with npm seems related to a cache bug, but fixing that didn’t resolve the module error.
  • I’m using macOS, and my user permissions seem fine, but the root-owned cache files may have caused the EACCES error.

This topic has been created from a Discord post (1298039628837687346) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

this is driving me absolutely crazy

Hi, having the same issue. Any luck?