Node.js 调试nuxt+;快速-未命中断点
我正在尝试开始使用nuxt+express。我从这里得到了代码:,在Node.js 调试nuxt+;快速-未命中断点,node.js,express,visual-studio-code,webstorm,nuxt.js,Node.js,Express,Visual Studio Code,Webstorm,Nuxt.js,我正在尝试开始使用nuxt+express。我从这里得到了代码:,在npm-run-dev中运行良好。我想调试API代码 在users.js文件中: import { Router } from 'express' var router = Router() // Mock Users const users = [ { name: 'Alexandre' }, { name: 'Sébastien' } ] /* GET users listing. */ router.get(
npm-run-dev
中运行良好。我想调试API代码
在users.js文件中:
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
和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"
}
}
这是我在VS代码控制台中看到的:
Debugging with legacy protocol because Node.js v7.4.0 was detected.
node --debug-brk=42131 --nolazy build\main.js
Debugger listening on 127.0.0.1:42131
Server listening on 127.0.0.1:3000
DONE Compiled successfully in 5591ms9:28:41 PM
> Open http://127.0.0.1:3000
我发现
"protocol": "inspector"
对launch.json中的配置进行修改可修复此问题并允许命中断点。是否调用listen方法?我的意思是,你看到服务器在控制台中运行吗?我看到服务器在控制台中运行。我将把它添加到问题中。
"protocol": "inspector"