title: "npm run build" = "react-scripts: Permission denied"
body: <p>I'm trying to deploy my working Windows 10 Spring-Boot/React app on Ubuntu 18.04 but keep getting "react-scripts: Permission denied" error despite numerous attempts to fix. Hopefully one of you react experts can spot what I'm doing wrong.</p>
  
  <p>My package.json looks like this</p>
  
  <pre><code>{
    "name": "medaverter-front",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
      "@testing-library/jest-dom": "^4.2.4",
      "@testing-library/react": "^9.3.2",
      "@testing-library/user-event": "^7.1.2",
      "axios": "^0.19.2",
      "bootstrap": "^4.4.1",
      "react": "^16.13.0",
      "react-dom": "^16.13.0",
      "react-router-dom": "^5.1.2",
      "react-scripts": "3.4.0",
      "react-table-6": "^6.11.0",
      "react-validation": "^3.0.7",
      "reactstrap": "^6.5.0",
      "validator": "^12.2.0"
    },
    "scripts": {
      "start": "react-scripts start",
      "build": "react-scripts build",
      "test": "react-scripts test",
      "eject": "react-scripts eject"
    },
    "eslintConfig": {
      "extends": "react-app"
    },
    "browserslist": {
      "production": [
        "&gt;0.2%",
        "not dead",
        "not op_mini all"
      ],
      "development": [
        "last 1 chrome version",
        "last 1 firefox version",
        "last 1 safari version"
      ]
    }
  }
  </code></pre>
  
  <p>I'm logged in as root and used nvm to install node and lts. I installed nvm like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
  </code></pre>
  
  <p>then did this:</p>
  
  <pre><code>nvm install node
  nvm use node
  nvm install --lts
  nvm use --lts
  </code></pre>
  
  <p>Then I <code>cd</code> to <code>/var/lib/jenkins/workspace/MedAverter/medaverter-front</code> and install <code>node_modules</code> like this:</p>
  
  <pre><code>npm install -g
  </code></pre>
  
  <p>and then change the permissions to 777 recursively, like this:</p>
  
  <pre><code>chmod -R 777 node_modules
  </code></pre>
  
  <p>I also changed all the /root/.nvm permissions to 777 recursively, like this:</p>
  
  <pre><code>chmod -R 777 /root/.nvm
  </code></pre>
  
  <p>I can get it build once using</p>
  
  <pre><code>npm run build
  </code></pre>
  
  <p>but then I run a "Build Now" from Jenkins and it fails with the same </p>
  
  <blockquote>
    <pre class="lang-none prettyprint-override"><code>[[1;34mINFO[m] Running 'npm run build' in /var/lib/jenkins/workspace/MedAverter/medaverter-front
  [[1;34mINFO[m] [[1;34mINFO[m] &gt; medaverter-front@0.1.0 build /var/lib/jenkins/workspace/MedAverter/medaverter-front
  [[1;34mINFO[m] &gt; react-scripts build [[1;34mINFO[m] 
  [[1;31mERROR[m] sh: 1: **react-scripts: Permission denied**
  [[1;31mERROR[m] npm ERR! code ELIFECYCLE
  [[1;31mERROR[m] npm ERR! errno 126
  [[1;31mERROR[m] npm ERR! medaverter-front@0.1.0 build: `react-scripts build` 
  [[1;31mERROR[m] npm ERR! Exit status 126
  </code></pre>
  </blockquote>
  
  <p>Then I <code>cd</code> to <code>/var/lib/jenkins/workspace/MedAverter/medaverter-front</code> and run</p>
  
  <pre><code>npm run build
  </code></pre>
  
  <p>And also get the same error again:</p>
  
  <blockquote>
  <pre><code>&gt; root@ubuntu-s-1vcpu-1gb-nyc1-01:/var/lib/jenkins/workspace/MedAverter/medaverter-front#
  &gt; npm run build
  &gt; 
  &gt; &gt; medaverter-front@0.1.0 build /var/lib/jenkins/workspace/MedAverter/medaverter-front
  &gt; &gt; react-scripts build
  &gt; 
  &gt; sh: 1: **react-scripts: Permission denied** npm ERR! code ELIFECYCLE
  &gt; npm ERR! errno 126 npm ERR! medaverter-front@0.1.0 build:
  &gt; `react-scripts build` npm ERR! Exit status 126
  </code></pre>
  </blockquote>
  
  <p>I've literally spent days trying to figure this out.  Suggestions?</p>