Search code examples
javascriptnode.jsnodemon

Nodemon dont start the server.js


I recently started using Nodemon. But when I run this command "nodemon server.js", comes this:

nodemon server.js
[nodemon] 3.1.9
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,cjs,json
[nodemon] starting `node server.js tailwind.config.js`
[nodemon] clean exit - waiting for changes before restart

This is my package.json file:

{
  "devDependencies": {
    "crypto-browserify": "^3.12.1",
    "tailwindcss": "^3.4.17"
  },
  "dependencies": {
    "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
    "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
    "@otplib/preset-browser": "^12.0.1",
    "body-parser": "^1.20.3",
    "cors": "^2.8.5",
    "dotenv": "^16.4.7",
    "esbuild-plugins-node-modules-polyfill": "^1.6.8",
    "express": "^4.21.2",
    "grep": "^0.1.0",
    "motion": "^11.18.0",
    "mysql2": "^3.12.0",
    "otplib": "^12.0.1",
    "qrcode": "^1.5.4"
  },
  "name": "bandashboard",
  "version": "1.0.0",
  "main": "tailwind.config.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server.js",
    "dev": "nodemon server.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "type": "commonjs",
  "description": ""
}

The problem is that Nodemon tries to start two files. How can I fix it? I have no nodemon.json file or similar. I installed Nodemon with npm install nodemon


Solution

  • The issue is caused by the "main": "tailwind.config.js" property in your package.json file. When you run nodemon server.js, nodemon reads the main property and tries to include tailwind.config.js as well.

    Update the "main" property in package.json to point to your entry file, server.js