Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run typeorm-ts-node-commonjs CLI script in docker node container #8818

Closed
cduff opened this issue Mar 28, 2022 · 6 comments · Fixed by #8821
Closed

Can't run typeorm-ts-node-commonjs CLI script in docker node container #8818

cduff opened this issue Mar 28, 2022 · 6 comments · Fixed by #8821

Comments

@cduff
Copy link
Contributor

cduff commented Mar 28, 2022

Issue Description

Expected Behavior

Should be able to run CLI commands from within docker containers.

Actual Behavior

My CI/CD pipeline now fails to run the typeorm migration:run command with the following error:

/usr/bin/env: 'node --require ts-node/register': No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines

Steps to Reproduce

Create a Dockerfile with the following content and try to build it:

FROM node:16.14.2
WORKDIR /usr/src/app
RUN echo "{\"dependencies\":{\"typeorm\":\"0.3.4\"},\"scripts\":{\"typeorm\":\"typeorm-ts-node-commonjs\"}}" > package.json
RUN npm i
RUN npm run typeorm

My Environment

windows 10
node 16.14.2
docker desktop 4.6.1

Additional Context

#8776

Relevant Database Driver(s)

n/a

Are you willing to resolve this issue by submitting a Pull Request?

  • ✖️ Yes, I have the time, and I know how to start.
  • ✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✖️ No, I don’t have the time, but I can support (using donations) development.
  • ✅ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
@pleerock
Copy link
Member

maybe you do not have ts-node installed?

@alt-art
Copy link

alt-art commented Mar 28, 2022

I have the same problem

@carlswann
Copy link

Same on CI :(

giladgd added a commit to giladgd/typeorm that referenced this issue Mar 28, 2022
…node-esm` on some linux distros

Changed to nodejs workaround instead of relying on shebang parameters, as they work a bit differently on some linux distros, and using the "-S" parameter breaks the CLI on Windows

Closes typeorm#8818
@giladgd
Copy link
Contributor

giladgd commented Mar 28, 2022

I've opened PR #8821 to fix this issue

@cduff
Copy link
Contributor Author

cduff commented Mar 29, 2022

maybe you do not have ts-node installed?

@pleerock the result is the same if ts-node is installed. For example the Dockerfile below now includes ts-node and yields the same result.

FROM node:16.14.2
WORKDIR /usr/src/app
RUN echo "{\"dependencies\":{\"ts-node\":\"10.7.0\",\"typeorm\":\"0.3.4\"},\"scripts\":{\"typeorm\":\"typeorm-ts-node-commonjs\"}}" > package.json
RUN npm i
RUN npm run typeorm

As mentioned by @giladgd in #8821 the issue is caused by incompatibility of shebang parameters across various linux distros.

pleerock pushed a commit that referenced this issue Mar 29, 2022
…node-esm` on some linux distros (#8821)

Changed to nodejs workaround instead of relying on shebang parameters, as they work a bit differently on some linux distros, and using the "-S" parameter breaks the CLI on Windows

Closes #8818
M-TGH pushed a commit to TradeCast/typeorm that referenced this issue Mar 29, 2022
…node-esm` on some linux distros (typeorm#8821)

Changed to nodejs workaround instead of relying on shebang parameters, as they work a bit differently on some linux distros, and using the "-S" parameter breaks the CLI on Windows

Closes typeorm#8818
@cduff
Copy link
Contributor Author

cduff commented Apr 6, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants