Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

285
Visualizações
EJS File having trouble finding script file after converting JS project to Typescript

Folder structure:

  • root:
    • dist:
      • FOLDER 'models' (models for mongoose/mongodb)
      • this is also where I store the Typescript compiled JS files, such as script.js.
    • src
      • FOLDER 'models' files to be compiled for mongoose models
      • FOLDER 'assets' (photos, thumbnails, etc)
      • FOLDER 'css' (for the entire project)
      • This is where these files live: server.ts, script.ts, and other misc scripting files that all get compiled by typescript.
    • FOLDER 'views':
      • EJS layouts and body files. For example, layout.ejs and home.ejs (body of layout.ejs)
    • also at root are: package-lock.json, .env, .gitignore, package.json, and tsconfig.json

Now onto the problem i'm facing...

I'm very new to Typescript but was able to convert many of these files including server.js and script.js (the main two files of this program) to Typescript. They currently have no errors pre-compilation, but the home.ejs file (in views) can not find the script.js file.

When using in my ejs files, should i aim to the script.js that has been compiled down? Or should I aim to the script.ts in my src folder? I was able to link to the script.js but when I converted the file to TS, the EJS file can no longer find it in browser.

Here is the code that is relevant for my home.ejs file:

<body>

 <script src="/dist/script.js"></script>
 <script src="/launch.js"></script>

</body>

And here is a screenshot, if it helps, of my current structure: Image of folder structure

For the line, I have tried all of these but they don't work:

<script src="/dist/script.js"></script>
<script src="./dist/script.js"></script>
<script src="../dist/script.js"></script>
<script src="../../dist/script.js"></script>

Also knowing if node should run the server.js (compiled) file or the server.ts (uncompiled) would be helpful!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda