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

Having trouble with the npm install command for setting up the Angular dual list box feature

I attempted to run the npm i angular-dual-listbox --save command, but encountered numerous errors indicating version discrepancies despite having version 8.2.14. I referred to this article: npmjs. The error log is as shown below: C:\GUNEET KAUR\P ...

Encountered an npm installation error with code EBADPLATFORM

Attempting to execute npm install resulted in the following error: $ npm install npm ERR! code EBADPLATFORM npm ERR! notsup Unsupported platform for <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5036233526353e242310617e617e63 ...

Having trouble initializing a new React project with 'npx create-react-app'?

When attempting to use npx create-react app, I encountered the errors below: npm ERR! code ENOENT npm ERR! syscall lstat npm ERR! path C:\Users\Administrator npm ERR! errno -4058 npm ERR! enoent ENOENT: no such file or directory, lstat 'C:&b ...

Uninstall the npm package "reload"

Looking for assistance with Ubuntu 14.04. Yesterday, I attempted to set up an "auto-reload" feature for node.js using supervisor + reload. Initially everything was working fine, but after a few reboots, severe lagging started occurring. Upon investigation ...

Exploring the benefits of integrating Apache Thrift with TypeScript

After running the apache thrift compiler, I now have generated .js and .d.ts files. How do I incorporate these files into my current Angular2/Typescript project? I attempted to do so with the following lines of code: ///<reference path="./thrift.d.ts"/ ...

Define security JWT token in the TypeScript REST API using the swagger annotations

Utilizing typescript-rest and incorporating swagger, a package known as typescript-rest-swagger has been integrated. Efforts to include the Bearer token into swagger have proven unsuccessful thus far. Removing the authorization middleware seems to allow ...

I am facing an issue with the Tailwind Flowbite Datepicker dropdown UI when running "npm run prod" for minification. The class is not being added during minification on the npm

I have successfully integrated a Laravel project with Tailwind CSS. I have also implemented the Flowbite Datepicker using a CDN to include the necessary JavaScript. Initially, everything was working fine and the date-picker was displaying correctly. Howev ...

What is the best way to send multiple data using GetServerSideProps?

I have a challenge where I need to pass multiple sets of sanity data into a component, but I am restricted to using getServerSideProps only once. How can I work around this limitation to include more than one set of sanity data? pages > members.tsx exp ...

What is the best way to invoke a function only once in typescript?

Struggling to implement TypeScript in React Native for fetching an API on screen load? I've been facing a tough time with it, especially when trying to call the function only once without using timeouts. Here's my current approach, but it's ...

NPM fails to execute in MAC Terminal

Encountering issues running npm on my Mac, even after trying to uninstall and reinstall it properly. The error message persists every time: Error: EEXIST: file already exists, mkdir '/usr/local/bin/npm' TypeError: Cannot read property 'load ...

In TypeScript, what is the return Type of sequelize.define()?

After hearing great things about TypeScript and its benefits of static typing, I decided to give it a try. I wanted to test it out by creating a simple web API with sequelize, but I'm struggling to understand the types returned from sequelize. Here ar ...

Encountering a type mismatch error in Typescript while working with Redux state in a store file

It appears that I have correctly identified all the types, but could there be a different type of Reducer missing? 'IinitialAssetsState' is not assignable to type 'Reducer' The complete error message: Type '(state: { assets: n ...

Vue.js and TypeScript combination may result in a 'null' value when using file input

I am attempting to detect an event once a file has been uploaded using a file input. Here is the JavaScript code: fileSelected(e: Event) { if ((<HTMLInputElement>e.target).files !== null && (<HTMLInputElement>e.target).files[0] !== null) { ...

Error occurred during npm build with Browserify: Module not found

When I run npm build with the following command: "build": "browserify -t [ babelify --presets [ es2015 react ] ] app/assets/app.jsx -o public/javascripts/app.js" I encounter the error message below: Error: Cannot find module 'components/maininput.j ...

To switch to desktop mode, double click; for mobile view, just tap once

I am looking to implement 2 different gestures for a specific feature in my application. Ideally, I want users to be able to double click on a card to open it in desktop view, but if they are using a phone, a single tap should suffice. How can I achieve th ...

angular2 and ionic2 encounter issues when handling requests with observable and promises

I am attempting to trigger an action once a promise request has been resolved, but I'm having trouble figuring out how to achieve this. After doing some research, I learned that Ionic2 storage.get() returns a promise, and I would like to make an HTTP ...

Tips for updating node modules following an upgrade of node.js version

After updating my node.js version from 9.x.x to 12.x.x, I was wondering if I need to rebuild all of my old node modules to connect them with the new node.js version. How can this be done? If I run the command (from Windows) "npm rebuild /node_modules" with ...

"Unlocking the Power of Colormap in JavaScript: A Comprehensive

I am in need of incorporating a colormap into my JavaScript page. My server side is powered by Flask, written in Python. To render colormaps on the client side, I have a JavaScript file that requires the colormap module (installed using "npm install colorm ...

Unable to transfer PNG files using the express route

I am facing an issue with rendering a PNG image served from my express endpoint. I have the image stored as a buffer in node, but despite my efforts, I am unable to display it correctly on the webpage. Current Situation https://i.stack.imgur.com/vRQjB.pn ...

Building Components on the Fly with Angular 5

I've been utilizing code similar to this to dynamically generate components within my application. These components need to support dynamic inputs. However, upon attempting to upgrade to Angular 5, I've encountered an issue with ReflectiveInjecto ...