What steps are required to generate dist/app.js from a script file in my TypeScript project?

I am currently working on a project using node, express, and TypeScript. When I run npm run build, everything builds without any issues. However, when I attempt to run npm run start, I encounter the following error:

@ruler-mobility/[email protected] /Users/macbook/Desktop/ruler
> npm run serve


> @ruler-mobility/[email protected] serve /Users/macbook/Desktop/ruler
> node dist/app.js

npm ERR! code ELIFECYCLE
 npm ERR! errno 1
 npm ERR! @ruler-mobility/[email protected] serve: `node dist/app.js`
 npm ERR! Exit status 1
 npm ERR! 
 npm ERR! The script '@ruler-mobility/[email protected] serve' failed.
 npm ERR! This is likely not a problem with npm. Additional logging output can be found above.

 npm ERR! A complete log of this run can be found in:
 npm ERR!     /Users/macbook/.npm/_logs/2020-02-21T20_53_55_009Z-debug.log
 npm ERR! code ELIFECYCLE
 npm ERR! errno 1
 npm ERR! @ruler-mobility/[email protected] start: `npm run serve`
 npm ERR! Exit status 1
 npm ERR! 
 npm ERR! The script '@ruler-mobility/[email protected] start' failed.
 npm ERR! This is likely not a problem with npm. Additional logging output can be found above.

 npm ERR! A complete log of this run can be found in:
 npm ERR!     /Users/macbook/.npm/_logs/2020-02-21T20_53_55_045Z-debug.log

Note: 'ruler' is the name of the project.

The scripts defined in my package.json are structured as follows:

 "scripts": {
    "start": "npm run serve",
    "build": "npm run build-source",
    "serve": "node dist/app.js",
    "watch-node": "nodemon dist/app.js",
    // Other script configurations...
},   

Here is my tsconfig.json file:

{
"compilerOptions": {
    // Compiler options listed here...
},
"exclude": ["node_modules", "**/*.spec.ts"]
}

As a beginner in TypeScript, could someone please guide me on how to correctly run my project?

Thank you.

Answer №1

The problem seems to be related to the location where webpack is generating your project files. Try removing the dist directory, executing npm run build, and verifying if the dist folder gets recreated to ensure that the output is being placed in the correct location.

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

The digest string for the crypto.pbkdf2Sync function is malfunctioning

I've been working on revamping the authentication system for an old application that previously ran on node 4.5, but I keep encountering an error whenever I attempt to log in. TypeError [ERR_INVALID_ARG_TYPE]: The "digest" argument must be one of type ...

Tips for composing content on a sanitized input?

In my small application, I have a feature where a question is displayed with certain words hidden and needs to be filled in by the user. The format of the question looks like this: The {0} {1} {2} his {3} off To achieve this functionality, I wrote the f ...

How can Material UI React handle long strings in menu text wrapping for both mobile and desktop devices?

Is there a way to ensure that long strings in an MUI Select component do not exceed the width and get cut off on mobile devices? How can I add a text-wrap or similar feature? Desktop: Mobile: <FormControl sx={{ m: 1, minWidth: '100%', marg ...

Issue with Typescript and eslint errors occurring exclusively in fresh code - Anticipated a colon.ts(1005)

Lately, in my extensive react-typescript project, I have encountered a peculiar issue. It seems that syntax errors are popping up everywhere, but only within the new code that I write. For instance, when creating a new component: import React from 're ...

Utilizing the power of HTML5 drag and drop functionality in conjunction with Angular Material 2's md

When working with Angular Material 2 and attempting to enable reordering of list elements, I encountered an issue where the functionality works perfectly for li-tag but fails with md-list-item. Why is that? Here is a snippet of my template: <md-nav-li ...

Event triggered by clicking on certain coordinates

Just starting with @asymmetrik/ngx-leaflet and Angular, so this might be a beginner's issue... I'm working on an Angular.io (v5) project that incorporates the @asymmetrik/ngx-leaflet-tutorial-ngcli Currently, I'm trying to retrieve the coo ...

Establishing the upstream branch tracking is essential after relocating and re-adding the remote URL in simple-git

In this particular section of code, the task at hand is to verify local repository existence and synchronize changes from a remote repository using simple-git. A problem I encountered involved JWT token expiration after 24 hours, which was resolved by remo ...

Leveraging React Native to position a view absolutely in the center of the screen without obstructing any other components

How can I center an image inside a view in the middle of the screen using position: "absolute"? The issue is that the view takes up 100% of the width and height of the screen, causing all components underneath it (such as input fields and buttons ...

Creation of source map for Ionic 2 TypeScript not successful

Struggling with debugging my Ionic 2 application and in need of guidance on how to include souceMap for each typescript file that corresponds to the javascript files. Despite enabling "sourceMap":true in my tsconfig.json file, the dev tools in Chrome do n ...

Implicated Generic in TypeScript

Is there a way to simplify my class A implementation? export class A<TB extends B<TC>, TC> implements TD<TB, TC> { make(): TC {} } Currently, I have to specify the TC type every time I create an instance of A: class CTest {} class BTes ...

What is the best way to create props that can accommodate three distinct types of functions in TypeScript?

I have been encountering a problem with the last function in my props interface that is supposed to support 3 different types of functions throughout the application. Despite adding parentheses as requested, I am still facing errors. // In Parent compon ...

"Although the Set-cookie is present in the response header, it is not being properly

I developed a GraphQL server using apollo-server-express, and it is currently running on localhost:4000. Upon sending a query from GraphQL playground, the response includes a set-cookie in the header: response header However, when checking the storage > ...

What is the best way to initiate the registration page through the @auth0/auth0-react library?

I've hit a roadblock in trying to automatically launch the sign-up (registration) page using @auth0/auth0-react. Previously, I would send mode which worked with auth0-js. So far, I have attempted the following without success: const { loginWithRedir ...

How to ensure Angular mat-button-toggle elements are perfectly aligned within their respective groups

https://i.stack.imgur.com/Wjtn5.png Hello there, I'm trying to make the numbers in the first group match the style of the second group (noche, mañana...). I've set both the group and individual element width to 100%, but the numbers beyond 22 ...

"String representation" compared to the method toString()

Currently, I am in the process of writing unit tests using jasmine. During this process, I encountered an issue with the following code snippet: let arg0: string = http.put.calls.argsFor(0) as string; if(arg0.search(...) This resulted in an error stating ...

Transition from using ReactDOM.render in favor of asynchronous callback to utilize createRoot()

Is there a React 18 equivalent of this code available? How does it handle the asynchronous part? ReactDOM.render(chart, container, async () => { //code that styles some chart cells and adds cells to a worksheet via exceljs }) ...

rendering mathematical formulae in a web browser with the help of mathjax and node.js

Wanting to download the node.js Mathjax library and run a demo example provided on GitHub page: https://github.com/mathjax/MathJax-node Here are the steps I have taken: Step 1: create mydemo directory Step 2: navigate to mydemo directory Step 3: npm i ...

strange complications with importing TypeScript

In my Typescript projects, I frequently use an npm module called common-types (repository: https://github.com/lifegadget/common-types). Recently, I added an enum for managing Firebase projects named FirebaseEvent. Here is how it is defined: export enum Fi ...

Several values are not equal to the typeorem parameter

I am looking for a way to create a Typeorm query that will return results similar to the following SQL statement: SELECT * FROM Users WHERE id <> 3 and id <> 8 and id <> 23; Any suggestions on how I can achieve this? Thank you! ...

What is the correct way to utilize window.scrollY effectively in my code?

Is it possible to have a fixed header that only appears when the user scrolls up, instead of being fixed at the top by default? I've tried using the "fixed" property but it ends up blocking the white stick at the top. Adjusting the z-index doesn&apos ...