最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to use node-inspector with `npm start` for my application? - Stack Overflow

programmeradmin1浏览0评论

I am using npm start to start my MEAN stack application, but I would like to use the node-inspector to debug some Mongoose. I know I can start the node inspector with node-inspector, but what can I substitute node --debug app.js with to make npm start work in my case?

This is my MEAN stack directory structure:

HTML        views/
Angular.js  public/javascript/
Express.js  routes/
Node.js     app.js
Mongoose js models/, connected in app.js
Mongo db    connected in app.js

For more information, this is my related question.

I am using npm start to start my MEAN stack application, but I would like to use the node-inspector to debug some Mongoose. I know I can start the node inspector with node-inspector, but what can I substitute node --debug app.js with to make npm start work in my case?

This is my MEAN stack directory structure:

HTML        views/
Angular.js  public/javascript/
Express.js  routes/
Node.js     app.js
Mongoose js models/, connected in app.js
Mongo db    connected in app.js

For more information, this is my related question.

Share Improve this question edited May 23, 2017 at 12:33 CommunityBot 11 silver badge asked Oct 12, 2015 at 21:16 MelissaMelissa 1,2765 gold badges13 silver badges30 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 13

You may want to add a seperate debug script to package.json. That way you won't have to remember to revert npm start when you're finished debugging.

"scripts": {
    "start": "node ./bin/www",
    "debug": "node --debug ./bin/www"
}

Start with npm run:

$ npm run debug

In package.json modify the start run command:

"scripts": {
    "start": "node --debug app.js"
}

I use it like this, I also set a variable and run the inspector in one command: npm run debug

"scripts": {
  "start": "set SOAPAPI=https://example.com/&&nodemon",
  "debug": "start node-inspector --web-port=8081&&set SOAPAPI=https://example.com/&&nodemon --debug"
}

*nodemon is an utility wrapper for node, you can use node instead

发布评论

评论列表(0)

  1. 暂无评论