0

I have a project written in Typescript which uses jasmine-ts to run a series of tests. I need to create a Docker container to run the tests for a few reasons.

Whilst the project locally runs OK npm test:

c:\github\gareththegeek\corewar>npm test

> [email protected] test c:\github\gareththegeek\corewar
> nyc jasmine-ts

Started
.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................


503 specs, 0 failures
Finished in 0.893 seconds 

When I containerise the same folder and run npm test from the docker image, the Typescript imports don't seem to be recognised.

c:\github\gareththegeek\corewar>docker run corewar

> [email protected] test /usr/src/app
> nyc jasmine-ts


/usr/src/app/node_modules/ts-node/src/index.ts:307
        throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset))
              ^
TSError: ⨯ Unable to compile TypeScript
parser/Expression.ts (1,29): Cannot find module './interface/IExpression'. (2307)
parser/Expression.ts (2,39): Cannot find module './interface/IToken'. (2307)
parser/Expression.ts (3,30): Cannot find module './interface/ITokenStream'. (230

My docker image is as basic as it comes:

FROM node:carbon

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
COPY package*.json ./

RUN npm install

# Bundle app source
COPY . .

CMD [ "npm", "test" ]

I'm really unsure why the docker container behaves differently to my local npm test command. I'm going to assume it's because locally I'm on windows and the docker container isn't. But I'm really unsure how to debug this.

Can anyone give any pointers on why Typescript imports aren't working within docker the way I'm expecting them too? I can paste over some of the Typescript code if it's any help.

1 Answer 1

3

Sigh ignore this question, I resolve the issue by realising that my includes referred to interface whereas for some reason the folder in Github was Interface.

I'd renamed all my folders locally through vscode, but this one hadn't updated git (even though others did :/).

I did the following:

cd parser

git mv Interface ifacetemp
git mv ifacetemp interface 

commit...
push...

This solved the issue, very annoying.

Sign up to request clarification or add additional context in comments.

2 Comments

Same with you, git ignore my case-sensitive files. set git config core.ignorecase false solved or use force push local repo to override remote
Thanks for this! I discovered that when running tsc from Windows command prompt, imports of other .ts files was not case sensitive. But when running tsc inside a Docker container that's based on Node image, it's case sensitive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.