Running "railway up" got deployment failure due to "error TS1127: Invalid character"
chris-opendata
HOBBYOP

2 months ago

My first time deployment today. Running "railway up" from Windows WSL Ubuntu got a build failure due to "error TS1127: Invalid character" in the log. Here is the content:

import { IsString, IsOptional, IsUUID, Min } from "class-validator";
export class GetAvailablePackagesDto {}
export class PurchasePackageDto {
  @IsUUID()
  packageId!: string;
}
export class GetUserPackagesDto {}

I have no problem with building it locally. I actually even ran "find packages -type f -name "*.ts" -exec dos2unix {} +" beforehand to ensure the removal of "^M" if any.

Could anyone shed some light on this?

Thanks

$10 Bounty

6 Replies

Status changed to Awaiting User Response Railway about 2 months ago


darseen
HOBBYTop 5% Contributor

2 months ago

Invalid character error is likely caused by BOM at the very beginning of your file. While dos2unix fixes line endings (CRLF vs LF), it often leaves the BOM.

If you are using VS Code, this is the easiest way to ensure the file is clean.

​1. Open the file causing the error.

​2. Look at the bottom right status bar. It likely says UTF-8 with BOM.

  1. ​Click that label.

​4. Select save with encoding.

​5. Choose UTF-8 (ensure it does not say "with BOM").

​6. Save the file and try railway up again.


chris-opendata
HOBBYOP

2 months ago

Thank you, Darseen, for your prompt suggestion. I verified the VSCode setting. It was not the case. I also did 'npx prettier --write .' with {

"endOfLine": "lf",

"embeddedLanguageFormatting": "auto"

}

However, the problem remains. As I deploy it from the local machine via Railway CLI, it may not be the usual way. So, it could be some bugs in the Railway CLI deployment tool that were not fully tested. I think it is something that the Railway development team should look into.


chris-opendata
HOBBYOP

2 months ago

I attached the file here for diagnosis. Note that I renamed it to .txt from .ts because the .ts file type is not supported by the upload function.

Attachments


ilyassbreth
FREE

2 months ago

i found someone on railway help station who had the exact same issue as you , railway up from wsl, every character throwing TS1127, and tsc seeing all files as one line.

they said adding a .dockerignore file fixed it for them, but they also mentioned they don't know why it worked. here's what they tried:

create .dockerignore in your project root:

node_modules/
.git
dist/
build/

worth noting that railway doesn't use .railwayignore anymore, just .dockerignore

i can't guarantee this will work since the person who fixed it didn't understand the root cause either, but it's worth trying since your symptoms match exactly. if it doesn't help, maybe try deploying via github integration instead of the cli as a workaround?

i hope this help you slightly_smiling_face emoji


ilyassbreth

i found someone on railway help station who had the exact same issue as you , railway up from wsl, every character throwing TS1127, and tsc seeing all files as one line.they said adding a .dockerignore file fixed it for them, but they also mentioned they don't know why it worked. here's what they tried:create .dockerignore in your project root:node_modules/ .git dist/ build/worth noting that railway doesn't use .railwayignore anymore, just .dockerignorei can't guarantee this will work since the person who fixed it didn't understand the root cause either, but it's worth trying since your symptoms match exactly. if it doesn't help, maybe try deploying via github integration instead of the cli as a workaround?i hope this help you

chris-opendata
HOBBYOP

2 months ago

Thank you, ilyassbreth, for your suggestion. I actually have this file that includes these items. So, it is something else. I am trying deployment from GitHub instead now.


ilyassbreth
FREE

2 months ago

github deployment should work fine since it bypasses the cli's file packaging entirely , railway just pulls directly from your repo. multiple people have confirmed that when railway up fails, github deployment succeeds


Loading...