Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

npm run build says react-scripts: Permission denied in CI

Errorsh: 1: react-scripts: Permission denied

Short answer

The shell found node_modules/.bin/react-scripts but may not run it. The usual causes are a node_modules folder that was copied or restored instead of installed, bin links skipped by an earlier install, or a workspace on a filesystem mounted noexec. Reinstall cleanly, rebuild the links, or move the job.

  • Applies to npm 10, npm 11, Node.js 22, Jenkins, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Look at the bin link and at how the workspace is mounted.

    ls -l node_modules/.bin/react-scripts
    findmnt -T . -o TARGET,OPTIONS
  2. 2Match what you see, then jump to its fix

    1. 1ls shows a link that is missing, broken or points to a file without execute permissionnode_modules was copied or restored, not installedFix
    2. 2The build user once ran npm with --no-bin-links or --ignore-scripts, or the folder sits on a share without symlinksAn earlier install skipped bin links or scriptsFix
    3. 3findmnt shows noexec in the options of the workspace mountThe workspace is on a noexec filesystemFix

What does the error look like?

  • sh: 1: react-scripts: Permission denied
  • sh: react-scripts: Permission denied

Cause 1 of 3

node_modules was copied or restored, not installed

1Check

npm links package executables into node_modules/.bin during install. A folder moved between machines, zipped, or restored from a cache can lose those links or their permissions.

ls -l node_modules/.bin | head

2Fix

Let npm build the folder itself. npm ci removes an existing node_modules before it installs from the lockfile.

npm ci

3Verify

Run the build.

npm run build

Confirmed by docs.npmjs.com

Did this fix it?

Cause 2 of 3

An earlier install skipped bin links or scripts

1Check

Bin links are created only when the bin-links setting is true, which is the default. Look for the flags in your CI job and in npm config.

npm config get bin-links
npm config get ignore-scripts

2Fix

Remove those flags, then ask npm to rebuild the links.

npm rebuild

3Verify

Check the link, then build.

ls -l node_modules/.bin/react-scripts
npm run build

Confirmed by docs.npmjs.com

Did this fix it?

Cause 3 of 3

The workspace is on a noexec filesystem

1Check

A mount with the noexec option does not permit direct execution of binaries on it, so even a correct link fails.

findmnt -T . -o TARGET,OPTIONS | grep noexec

2Fix

Run the build in a directory on a mount without noexec, or have the server admin change the mount options.

mkdir -p /var/build/my-app && cd /var/build/my-app
npm ci && npm run build

3Verify

The build starts and prints its normal output.

npm run build

Confirmed by man7.org

Did this fix it?

How do I stop it coming back?

  • Never commit or cache node_modules as the only source; cache the npm download cache and run npm ci.
  • Use npm ci in CI jobs so each build starts from a clean tree.
  • Keep build workspaces off noexec mounts.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.