Monday 8 May 2017

Debugging nuxt + Express - breakpoints not hit

I'm trying to get started with nuxt + express. I have the code from here: https://github.com/nuxt/express, running fine with npm run dev. I'd like to debug the API code. In the users.js file:

import { Router } from 'express'

var router = Router()

// Mock Users
const users = [
  { name: 'Alexandre' },
  { name: 'Sébastien' }
]

/* GET users listing. */
router.get('/users', function (req, res, next) {
  res.json(users)
})

/* GET user by ID. */
router.get('/users/:id', function (req, res, next) {
  var id = parseInt(req.params.id)
  if (id >= 0 && id < users.length) {
    res.json(users[id])
  } else {
    res.sendStatus(404)
  }
})

export default router

I've set breakpoints within both the get methods. I've tried with Web Storm as well as Visual Studio Code, but in both cases the breakpoints are not hit.

My launch.json file looks like this:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "program": "${workspaceRoot}\\build\\main.js"
    }
  ]
}

and package.json:

{
  "name": "learn-nuxt",
  "version": "1.0.0",
  "description": "Nuxt.js project",
  "author": "naveed",
  "private": true,
  "scripts": {
    "dev": "backpack",
    "build": "nuxt build && backpack build",
    "start": "cross-env NODE_ENV=production node build/main.js",
    "precommit": "npm run lint",
    "lint": "eslint --ext .js,.vue --ignore-path .gitignore ."
  },
  "dependencies": {
    "axios": "^0.16.1",
    "backpack-core": "^0.3.0",
    "cross-env": "^4.0.0",
    "express": "^4.14.0",
    "nuxt": "~0.10.6",
    "source-map-support": "^0.4.14"
  },
  "devDependencies": {
    "babel-eslint": "^7.1.1",
    "backpack-core": "^0.3.0",
    "eslint": "^3.13.1",
    "eslint-config-standard": "^10.2.1",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-html": "^2.0.1",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-node": "^4.2.2",
    "eslint-plugin-promise": "^3.4.0",
    "eslint-plugin-standard": "^3.0.1"
  }
}



via naveed

No comments:

Post a Comment