I'm trying to get create-react-app working on my Ubuntu wsl2 without having to install node, but rather using Docker. I have the following.
so I have this utility.docker-compose.yml file
version: '3.7'
services:
npm:
build:
context: .
dockerfile: utility.Dockerfile
volumes:
- ./:/app
stdin_open: true
tty: true
utility.Dockerfile
FROM node:18-alpine
WORKDIR /app
ENTRYPOINT [ "npm" ]
I also have a shell script
docker-compose -f utility.docker-compose.yml run --rm npm "init" "react-app" "my-app"
This is under my directory \wsl$\Ubuntu-20.04\home\username\Projects
I am able to install npm packages by modifying the shell script to something like "install" "axios". That works, but I haven't had luck trying to create a react app that.
I keep getting this error "sh: create-react-app: Permission denied" I tried changing the permissions and ownership but nothing works.
sh: create-react-app: Permission denied
npm ERR! code 127
npm ERR! path /app
npm ERR! command failed
npm ERR! command sh -c -- create-react-app my-app
But when I try it on my Windows10, it works easily. Any ideas on how to fix this issue? I kinda don't like to keep moving my files from Windows 10 to my WSl2 Ubuntu instance.
I prefer using wsl2 cause when I make a change in react, I can see the changes reflect right away as opposed to on Windows 10 I have to rebuild the containers.
So, I ended up finding another stackoverflow question that worked for my situation. I added the command below is what worked for me.
docker run -it -p 8080:80 -v $PWD:/app -w /app node:12-slim bash
The link below is the solution that worked for me.