Is nodemon waiting for file changes before restarting due to an app crash?

PS D:\CODE\2077\ONLINESHOP> npm run dev

> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="44372c2b3440">[email protected]</a> dev D:\CODE\2077\ONLINESHOP
> SET NODE_ENV=DEVELOPMENT& nodemon backend/server
  
> [nodemon] 2.1.3
> [nodemon] to restart at any time, enter `rs`
> [nodemon] watching path(s): *.*
> [nodemon] watching extensions: js,mjs,json
> [nodemon] starting `node backend/server.js`
> D:\CODE\2077\ONLINESHOP\backend\routes\product.js:6
> router.routes('/products').get(getProducts);
       ^

> TypeError: router.routes is not a function
>   at Object.<anonymous> (D:\CODE\2077\ONLINESHOP\backend\routes\product.js:6:8)
>   at Module._compile (internal/modules/cjs/loader.js:1063:30)
>   at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
>   at Module.load (internal/modules/cjs/loader.js:928:32)   
>   at Function.Module._load (internal/modules/cjs/loader.js:769:14)
>   at Module.require (internal/modules/cjs/loader.js:952:19)    at require >(internal/modules/cjs/helpers.js:88:18)       
>   at Object.<anonymous> (D:\CODE\2077\ONLINESHOP\backend\app.js:8:18)
>   at Module._compile (internal/modules/cjs/loader.js:1063:30)
>   at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
>   [nodemon] app crashed - waiting for file changes before starting...

Answer №1

The error message clearly indicates that you are attempting to invoke a variable as a function, which is not the correct syntax.

router.routes = ['/','/api','/ping'];
router.routes(); // This line causes an ERROR

It is important to verify the type of router.routes before trying to execute it as a function.

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

Generate a new style element, establish various classes, and append a class to the element

Is there a more efficient solution available? $("<style>") .attr("type", "text/css") .prependTo("head") .append(".bor {border:2px dotted red} .gto {padding:10px; font-size:medium}"); $("input:text").addClass("bor gto").val("Enter your t ...

Guide on generating a dynamic div element with v-for in Vue.js

I am looking to generate div elements dynamically based on the number of items in an array. These divs will include a ProgressBar.js HTML element. Here is the Vue.js code snippet for reference: import ProgressBar from 'progressbar.js' var bar ...

Swiper.IO pagination indicators not displaying

Why is the pagination not showing up on the image carousel I created with Swiper? Despite being in the DOM, it has a height of 0 and manual changes have no effect. Any suggestions? import Swiper from '../../vendor/swiper.min.js'; export default ...

'Unlawful invocation' problem occurs while attempting to upload a file using ajax

Having trouble with uploading a file using ajax as I keep running into an 'Illegal invocation' error when trying to pass the file. All other input fields are successfully passed (if I exclude the file). Here is a simplified version of my code: ...

Utilize unconventional characters in Marionette and Underscore templates to enhance your design

I am facing an issue with a model that has attributes named @id, @type, and others. When I attempt to include <%= @id %> in a template for a Marionette.ItemView (using Underscore), I encounter the following error: Uncaught SyntaxError: Unexpected ...

JSP form continues to submit despite JavaScript validation returning false

On my JSP page, I have a form named "deleteCont" and a JavaScript function called "validateDelete". When the user clicks the "Delete contact" button, the "validateDelete" function is triggered successfully, showing an alert message. Unfortunately, even whe ...

Converting TypeScript to ES5 in Angular 2: A Comprehensive Guide

I am currently diving into Angular 2 and delving into Typescript to create simple applications within the Angular 2 framework. What I have discovered is that with Typescript, we can utilize classes, interfaces, modules, and more to enhance our application ...

What is the process for installing a previous release of React?

Wondering how to set up an outdated version of React? Take a look at this snippet from my package.json file: "react": "^18.12.0", ...

How can I change the color of a designated column in a Google stacked bar chart by clicking a button?

I am in the process of creating a website that compares incoming students at my university across different academic years. We have successfully implemented a pie chart to display data for the selected year. Now, we aim to include a stacked bar chart next ...

Issue encountered with AJAX multiple image uploader

I'm attempting to create an PHP and JavaScript (jQuery using $.ajax) image uploader. HTML: <form method="post" action="php/inc.upload.php" id="upload-form" enctype="multipart/form-data"> <input type="file" id="file-input" name="file[]" a ...

Contrast between reactivex.io's rxjs class ES6 Observable and the Observable class found on rxjs.dev's API index

As I dive into learning RxJS, I stumbled upon two distinct definitions of Observable: https://reactivex.io/rxjs/class/es6/Observable.js~Observable.html https://rxjs.dev/api/index/class/Observable Which one holds the true definition? ...

VIDEOJS ERROR: A peculiar mistake has occurred. TypeError: The property 'value' cannot be read since it is undefined in the context of

Recently, I came across a fascinating plugin called videojs-thumbnails for video.js, and I'm eager to incorporate it into my angular component. However, I keep encountering an error that says: VIDEOJS: ERROR: TypeError: Cannot read property 'val ...

Function anomalies triggered by delayed setState updates with React Hooks

Creating a Quiz app with React involves fetching questions as an array and managing the following states: An array containing all question details - statement, options, chosen answer, status (answered, marked for review, unvisited); An object holding info ...

When clicking the next or previous button in VueJS, showcase a list

I am looking to create a case management system in a JavaScript view. The system will track employees arriving and leaving a department, returning 3 objects (entries and exits) for the current week, next week, and the week after that. By default, the syste ...

Unable to call Success function in JQuery AJAX request

Here is a simple JQuery ajax request I am working on: $.ajax("../ajax/data/items.json", { success: setContent, type: "GET", dataType: "json" }); function setContent(data, status, jqxhr) { alert("Hello!"); } The json file loads successfully with a 200 r ...

Tips for handling the rejection of a promise within a callback function in Node.js

How can we effectively incorporate a catch statement within a rejectionCallback function of a promise? Is it feasible or advisable to structure the code in this manner? Would the Promise object need to be passed into the rejection function in such a scena ...

How can you form a promise by combining multiple asynchronous file reads in Node.js?

Consider the following scenario: fn1() { [filepath1, filepath2, ..., filepathN].forEach(process); function process(path) { fs.readFile(file, translate); } } The callback function translate operates on the contents of each file. How can ...

Titanium: Picture -> "automatically"

Imagine there is an image named hello.png with the dimensions of 200x100. A button is then created using this hello.png as shown below: var btn = Titanium.UI.createButton({ bottom : 50, backgroundImage : "images/hello.png", width:100, height:"auto"; }); w ...

Using JavaScript to fetch HTML and apply CSS dynamically

Is there a way to retrieve all HTML within a div along with the corresponding CSS? A majority of the CSS is defined in classes within an external stylesheet. document.getElementById("mydiv") Currently, using the above code only fetches the HTML with inli ...

Eliminating the dynamic element in jQuery causes disruption to the ViewContainerRef container

In my Angular 2+ application, I am dynamically creating components using the following code snippet: @ViewChild("containerNode", { read: ViewContainerRef }) cardContainer; const factory = this.ComponentFactoryResolver.resolveComponentFactory(CardComponen ...