Npx gulp build permission denied

I recently learned that when editing a theme you need to run the command sudo npx gulp build.

However, after doing it today to add some plausible 404 error tracking into the Dope theme, I was prompted to install gulp@4.0.2. Ever since I said yes to that prompt, I’m getting a Permission denied response.

ghost-mgr@ghostUbuntu-NYC3:/var/www/ghost$ sudo npx gulp build
Need to install the following packages:
Ok to proceed? (y) y
npm WARN deprecated source-map-url@0.4.1: See
npm WARN deprecated urix@0.1.0: Please see
npm WARN deprecated resolve-url@0.2.1:
npm WARN deprecated source-map-resolve@0.5.3: See
npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
sh: 1: gulp: Permission denied

Needless to say, I’m not able to update the CSS on this theme. What should I do?

Ok, I solved my own problem, if it’s helpful for anyone else. I browsed to the theme directory I wanted to update the CSS for and ran the command sudo chmod -R a+x node_modules then I ran sudo npm install just to be sure, then when I tried sudo npx gulp build it worked.

All thanks to this post node.js - sh: 1: node: Permission denied - Stack Overflow