13

Im running express on windows 8. I ran the command

>express app

after i ran the command to install dependencies

>cd app && npm install

after i attempted to run the app using the given command

>DEBUG=my-application ./bin/www

but I received the error message

'Debug' is not recognized as an internal or external command,
operable program or batch file.

any ideas on how to fix this? Some background info, I successfully installed node.js from their website. I attempted to install express usings the commands

>npm install

when that didnt work i followed the instuctions on this website https://coderwall.com/p/mbov6w. when that didnt work i used the following command and it worked

npm install -g express-generator@3

i also made my own package.json and app.js based off the express website and i am now stuck.

B4dmonkey
  • 112
  • 1
  • 2
  • 12
  • 1
    possible duplicate of [Why can't I run my node.js express web application](http://stackoverflow.com/questions/23727413/why-cant-i-run-my-node-js-express-web-application) – mscdex Oct 08 '14 at 17:18

8 Answers8

14

For Windows : change your start command in the package.json file to

"scripts": {
    "start": "set DEBUG=my-application & node ./bin/www"   
}

then you can run npm start. There's no need to set the DEBUG environment variable in your cmd window first.

Bart
  • 141
  • 1
  • 2
11

First, you must set DEBUG as a environment variable:

set DEBUG=my-application

then, you can run the app:

node bin/www
Aaronidas
  • 138
  • 2
  • 7
7

In your root folder of your project you have to run this command

For Windows:

set DEBUG=express:* & node bin/www
Hamid
  • 2,852
  • 1
  • 28
  • 45
4

For windows environments you need to use SET VARIABLE for example

"scripts" : {
   "start" : "SET DEBUG=app & node ./bin/www"
}

That will help you with windows env but if you want to use cross platform I recommend to install this library cross-env that library will help you to set variables for windows and linux environments. And the json should look like this:

"scripts" : {
    "start" : "cross-env DEBUG=app & node ./bin/www"
}

I was having same issue and this help me!

GeekDev
  • 385
  • 3
  • 16
4

use this settings on your package.json

For window Users..

  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "set DEBUG=app & node app.js"
  },

For Mac Users

  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "DEBUG=app node app.js"
  },

app is your-app-name such as [app.js][server.js] etc.

3

Follow the following steps for windows:

  1. Go to your application i.e. cd app
  2. npm install
  3. set DEBUG=app
  4. npm start

It will start listening on port 3000 by default.

Krunal Shah
  • 653
  • 2
  • 10
  • 16
0

This fixed my issue :

    "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node src/index.js"
  }
Abhishek Sengupta
  • 2,938
  • 1
  • 28
  • 35
0

The below command is for the windows users running on Git Bash with nodemon.

"scripts": {
"start": "node index.js",
"dev": "SET DEBUG=app:* & nodemon index.js"
}