const error = new TypeError(`${calculateRelativePath(cwd, fileName)}: Skipping emission of file`);

Hey there! I have a typescript code snippet that looks like this:

import { getConnection } from "typeorm";
import { GraphQLClient } from "graphql-request";
import got from "got";
import database from "./utils/database";
...

Whenever I run the following command:

cross-env NODE_ENV=development ts-node  src/scripts/createApp.ts http://localhost:3010/graphql

I encounter an error message that says:

throw new TypeError(`${relative(cwd, fileName)}: Emit skipped`)
              ^
TypeError: src/scripts/utils/database.js: Emit skipped

database.js

import { createConnection, getConnectionOptions, getConnection } from "typeorm";

export default {
  async connect(): Promise<void> {
    const connectionOptions = await getConnectionOptions(process.env.NODE_ENV);
    await createConnection({
      ...connectionOptions,
      name: "default",
    });
  },
  disconnect(): Promise<void> {
    return getConnection().close();
  },
};

Could you please help me locate the error? Additionally, do you have any suggestions for how to resolve it?

Thanks a ton!

Answer №1

The recommended approach to solve the issue is by modifying the tsconfig file.

"allowJs": false,

Answer №2

In a situation similar to mine, I found that modifying the tsconfig.json file was necessary. Specifically, setting allowJs to true was crucial because I had some automatically generated JavaScript code within my codebase. These pre-compiled validators for JSON Schema files needed to be included in the output.

To resolve the issue, I discovered that it stemmed from incorrectly compiled TypeScript files overlapping with JavaScript files in the same directory. Once I cleared my workspace, ts-node functioned correctly, allowing both TypeScript and the few auto-generated JavaScript files to work seamlessly.

Answer №3

From my perspective, the problem was resolved by fixing an issue with the updated version.

To address this, I used yarn add ts-node --dev or npm i --save-dev ts-node

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the alternative HTML file to use for displaying web content if render is not being utilized?

When creating a project in Node.js without using render, which HTML file will be used to display content on the web with res.send('respond with a resource')? app.js var createError = require('http-errors'); var express = require(' ...

Express Node receives two incoming requests from a single remote AJAX request

When I make a simple ajax call, my server-side debugger (node) always shows 2 calls being made. Initially, I suspected it was due to the favicon, but upon further investigation, I don't think that's the case. I attempted to handle the favicon s ...

Inter-component communication in Angular

I am working with two components: CategoryComponent and CategoryProductComponent, as well as a service called CartegoryService. The CategoryComponent displays a table of categories fetched from the CategoryService. Each row in the table has a button that r ...

Exploring objects nested within other types in Typescript is a powerful tool for

My journey with TypeScript is still in its early stages, and I find myself grappling with a specific challenge. The structure I am working with is as follows: I have a function that populates data for a timeline component. The data passed to this function ...

The text in the AJAX file is visible in the network tab, but it is not appearing on the screen

//server.js Here is my node.js server code. I am currently focusing on understanding the basics of Node before diving into Express. Backend development in general can be a bit confusing for me. var http = require('http'); var fs = require(&apos ...

Does Peerjs exclusively cater to one-on-one webrtc communication?

Can PeerJS be used to implement one-to-many audio communication with WebRTC? I'm currently using Socket.io with Node.js. Is this sufficient for WebRTC integration? As a beginner in WebRTC, could you recommend some options for implementin ...

Building a Dynamic Checkbox Validation Feature in Angular Using Data retrieved from an API

Currently, I have a function that retrieves and displays a list obtained from an API: displayEventTicketDetails() { this.Service .getEventTicketDetails().subscribe((data: any) => { this.eventTicketDetails = data.map(ticket => ticket. ...

Removing Email from Firebase Using Firebase Admin Node JS SDK

I need to remove Email from a user who already has both a Phone Number and Email linked. This is what I tried: admin.auth().updateUser("user uid", { email: null, password: null, }) .then(function(userRecord) { // Check the UserRecord re ...

Oops! The Element Type provided is not valid - it should be a string

I have a desire to transition from using Victory Native to Victory Native XL. However, I am encountering an error message saying Render Error Element type is invalid. import * as React from "react"; import { View } from "react-native"; ...

Error: In Node.js, when passing a SQL query, the callback argument must be a function

Below is the code snippet : application.post('/Modification/SaveEdit/:idd',function(req,res){ var mem = req.body.memo; connection.query('UPDATE memos SET textMemo = ?',mem,'WHERE idMemo = ?',req.params.idd, function (erro ...

What is the proper way to include type annotation in a destructured object literal when using the rest operator?

When working with objects, I utilize the spread/rest operator to destructure an object literal. Is there a way to add type annotation specifically to the rest part? I attempted to accomplish this task, but encountered an error when running tsc. const { ...

Transform a collection of objects into instances of a class

I have a scenario where I am fetching an array of objects from PHP and my goal is to transform this data into instances of a class called ContentData. The current solution that I have seems to work fine, but deep down I sense that there might be a more el ...

Node.js middleware designed for handling unique requests

My request is for middleware to be applied specifically to certain routes: POST /tickets PUT /tickets/:id DELETE /tickets/:id etc... Currently, the middleware I have implemented runs for all HTTP requests made on /tickets and similar routes: app.use(&ap ...

Receiving corrupt files while pulling image data from node server (using gridfs-stream)

After conducting an extensive search on platforms like Stack Overflow and Reddit, as well as going through numerous related posts, I decided to share my experience. Even though it's been a bit of a struggle, I refuse to give up so easily :) The proce ...

A guide on utilizing multer-sftp for downloading files

I've been working on this code, but after searching online I still haven't found a way to download a file from the remote server. I can successfully upload files to the server, but downloading them is posing a challenge. var storage = sftpStorag ...

Route all Express JS paths to a static maintenance page

Need help with setting up a static Under construction page for an Angular Web App with Express Node JS Backend. I have a function called initStaticPages that initializes all routes and have added a new Page served via /maintenance. However, when trying to ...

I am currently facing an issue related to the length property. It is showing an ERROR TypeError: Cannot read property 'length' of undefined

Is it recommended to set the length to be inherited from Angular right? If so, why am I getting this error: "MyPostsComponent.html: 7 ERROR TypeError: Cannot read the 'length' of undefined property" when fileList.length is greater than 0? onFile ...

Error message: Log file cannot be located on Heroku server

When troubleshooting an app on Heroku, I encounter the following message in the log console: ............ app[web.1]: app[web.1]: npm ERR! A detailed log of this run can be accessed at: app[web.1]: npm ERR! /app/.npm/_logs/2017-08-19T03_00_34_428Z ...

In order to showcase the data from the second JSON by using the unique identifier

SCENARIO: I currently have two JSON files named contacts and workers: contacts [ { "name": "Jhon Doe", "gender": "Male", "workers": [ "e39f9302-77b3-4c52-a858-adb67651ce86", "38688c41-8fda-41d7-b0f5-c37dce3f5374" ] }, { "name": "Peter ...

Customizing a function in a mongoose model

I currently have an express route set up like this: app.post('/users/me', (req, res) => { var body = req.body.email; User.find({ email: body }).then((user) => { res.send({user}); }, (e) => { res.s ...