Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSym: not found while executing binary in Docker on Windows

I am using Docker on windows.

Error:

Step 4/5 : RUN npm install -g
 ---> Running in ec6582e10f69
+ [email protected]
added 1 package in 0.437s
Removing intermediate container ec6582e10f69
 ---> f2b9a25a51a3
Step 5/5 : RUN npm run build-tsc
 ---> Running in 6321ac31e370

> [email protected] build-tsc /app
> tsc

/app/node_modules/.bin/tsc: line 1: XSym: not found
/app/node_modules/.bin/tsc: line 2: 0021: not found
/app/node_modules/.bin/tsc: line 3: 8cbd85238d8fbeb66a0afc1d79bcd880: not found
/app/node_modules/.bin/tsc: line 4: ../typescript/bin/tsc: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] build-tsc: `tsc`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] build-tsc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-02-17T09_27_42_522Z-debug.log
ERROR: Service 'auth' failed to build: The command '/bin/sh -c npm run build-tsc' returned a non-zero code: 1

Dockerfile:

FROM node:8.15.0-alpine

ADD . /app/
WORKDIR /app

RUN npm install -g
RUN npm run build-tsc

package.json:

"scripts": {
    ...
    "build-tsc": "tsc",
    ...
  },
"dependencies": {
    ...
    "typescript": "^3.3.3"
  }

If I try to run the same command inside a terminal in the docker container it works perfectly. Using docker-compose if I put it in the command field it also works fine.

like image 331
Sarthak Singh Avatar asked Feb 17 '19 09:02

Sarthak Singh


People also ask

Can I run Docker desktop inside an ESXi or azure VM?

Running Docker Desktop inside a VMware ESXi or Azure VM is supported for Docker Business customers. It requires enabling nested virtualization on the hypervisor first. For more information, see Running Docker Desktop in a VM or VDI environment. Looking for information on using Windows containers?

How to fix Docker can not execute the shell script?

If you look at the above error then you can see docker can not execute the shell script(my-custom-script.sh) How to fix it? Make sure the script my-custom-script.sh is available - the First check which you should perform is by checking the shell script my-custom-script.sh if it's available or not.

What does exec Python mean in Docker?

Generally, we tend to focus on the remaining part of the error but if you look carefully in the above error then it stats the exec: "python" which mean the docker entrypoint_ is not able to run or execute the python program_. How to fix it?

How to install Docker desktop on Windows?

Install 🔗 Follow the usual installation instructions to install Docker Desktop. If you are running a supported system, Docker... Start Docker Desktop from the Windows Start menu. From the Docker menu, select Settings > General. Select the Use WSL 2 based engine check box. If you have installed ...


1 Answers

I see this problem with react-scripts build when I have my Windows node_modules/ folder mounted inside the Linux container. Most likely, you ran npm install in Windows then copied node_modules/ into your image on build, or you have your local project folder mounted as a Docker volume. Either way, you are trying to run a Windows executable on Linux and it blows up.

Technically it happens because content of binary file /app/node_modules/.bin/tsc looks like

XSym
0021
8cbd85238d8fbeb66a0afc1d79bcd880
../typescript/bin/tsc 

You should be able to work around the build-time issue by adding node_modules/ to your .dockerignore file.

If, like me, you later mount the local project directory inside the container for development purposes, you will still have to throw away the node_modules/ folder manually and run npm install again from inside the container.

like image 112
Derek Avatar answered Sep 29 '22 09:09

Derek