我正在处理的项目在端口6379上有Redis,在端口5000上有节点服务器。我通过运行npm run server运行服务器,我的package.json脚本如下所示:
webpack --watch --progress --config ./build/server/webpack.dev.js在端口5000上添加Attach to Node.js/Chrome的配置并单击WebStorm中的错误图标时,我无法附加调试器。
我得到了invalid response from the remote host
我是否应该为我的包JSON脚本打一个--inspect选项?
编辑:我把inspect传给了nodemon。我现在可以连接到调试器了,但是我的断点没有挂起。webpack的配置如下:
const commonWebpackConfig = require('./webpack.common')
const merge = require('webpack-merge')
const NodemonPlugin = require('nodemon-webpack-plugin')
module.exports = merge(commonWebpackConfig, {
mode: 'development',
plugins: [
new NodemonPlugin({
nodeArgs: [ '--inspect'],
script: './dist/server.js'
})
]
})
const path = require('path')
const webpack = require('webpack')
const nodeExternals = require('webpack-node-externals')
module.exports = {
entry: {
server: path.join(__dirname, '..', '..', 'server', 'app.js'),
},
output: {
path: path.join(__dirname, '..', '..', 'dist'),
publicPath: '/',
filename: '[name].js'
},
target: 'node',
node: {
__dirname: false,
__filename: false,
},
externals: [nodeExternals()],
resolve: {
extensions: ['.js']
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [
['@babel/plugin-proposal-class-properties', {'loose': false}]
]
}
}
}
]
}
}我发现了断点映射问题。我需要添加以下内容:
devtool: "eval-source-map",
编辑:
我认为断点并不能完全支持异步/等待的代码块
发布于 2019-07-17 05:34:36
我能让它正常工作。我们使用的是nodemon- Lena plugin,所以我需要像莉娜说的那样传入nodeArgs。我向它传递了--inspect,默认情况下是端口9229。
然后我必须添加devtools: "eval-source-map,这样我的断点才能有正确的映射。
编辑:
我认为断点并不能完全支持异步/等待的代码块
https://stackoverflow.com/questions/57047728
复制相似问题