question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

permission denied react-scripts when running in docker

See original GitHub issue

I am trying to run my app in a docker container and deploy it to elastic beanstalk. i received the following error:

Step 7 : RUN npm run build
  Running in 07e37004f950
  npm info it worked if it ends with ok
  npm info using npm@3.10.3
  npm info using node@v6.4.0
  npm info lifecycle LiveOn@0.0.1~prebuild: LiveOn@0.0.1
  npm info lifecycle LiveOn@0.0.1~build: LiveOn@0.0.1

  > LiveOn@0.0.1 build /usr/src/app
  > react-scripts build

  sh: 1: react-scripts: Permission denied

  npm info lifecycle LiveOn@0.0.1~build: Failed to exec build script
  npm ERR! Linux 4.4.16-27.56.amzn1.x86_64
  npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
  npm ERR! node v6.4.0
  npm ERR! npm  v3.10.3
  npm ERR! code ELIFECYCLE
  npm ERR! LiveOn@0.0.1 build: `react-scripts build`
  npm ERR! Exit status 126

my docker file is:

# Dockerfile
FROM node:6

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install

# Bundle app source
COPY . /usr/src/app

# Build and optimize react app
RUN npm run build

EXPOSE 9000

# defined in package.json
CMD [ "npm", "run", "start:server" ]

And my Dockerrun.aws.json is:

{
 "AWSEBDockerrunVersion": "1",

  "Ports": [
    {
      "ContainerPort": "9000"
    }
  ],

  "Volumes": [
    {
      "HostDirectory": "/var/app/current",
      "ContainerDirectory": "/usr/src/app"
    }
  ]
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
gaearoncommented, Aug 28, 2016

Maybe 73c940a will fix this.

Can you try running

chmod a+x app/node_modules/.bin/react-scripts

?

I assumed Node does this automatically but maybe not.

2reactions
jversozacommented, May 4, 2018

@skeletorkun …not an issue with create-react-app, chromeos sets noexec flag on sdcards: https://github.com/dnschneid/crouton/issues/3423

One workaround is running react-scripts.js using node react-scripts.js instead of ./react-scripts (so, for example, in package.json…“start”: “node ./node_modules/react-scripts/bin/react-scripts.js start”).

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - "npm run build" = "react-scripts: Permission denied"
Solution 1: I think you have react-script globally installed. so try this command npm install react-scripts --save.
Read more >
Docker: npm permission denied - Code with Mosh Forum
My local machine is running Ubuntu and when I run this command: sudo docker build -t react-app . I get this error from...
Read more >
[Solved]-"npm run build" = "react-scripts: Permission denied"
Solution 1: I think you have react-script globally installed. so try this command npm install react-scripts --save. and then run the application again....
Read more >
Permission Denied When Installing NPM Packages With Docker
I have the following Dockerfile for a React app: ## base image FROM node:11.12.0-alpine ## set working directory WORKDIR /usr/src/app ## add ...
Read more >
react-scripts not found docker - You.com | The AI Search ...
With a normal installation, docker should have access to your resource. But I have seen on my coworker's machine there were some weird...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found