Javascript 带nodemon插件的VS代码调试网页包:未绑定断点
我正在为我未来的express js项目创建一个模板 目前我想设置调试。 但我总是得到未绑定的断点 以下是我认为很重要的文件(它们很长,很抱歉):Javascript 带nodemon插件的VS代码调试网页包:未绑定断点,javascript,node.js,debugging,webpack,visual-studio-code,Javascript,Node.js,Debugging,Webpack,Visual Studio Code,我正在为我未来的express js项目创建一个模板 目前我想设置调试。 但我总是得到未绑定的断点 以下是我认为很重要的文件(它们很长,很抱歉): package.json webpack.config.js launch.json 文件夹结构 未绑定断点错误 控制台输出 package.json { "dependencies": { "bcryptjs": "^2.4.3", "body-parse
- package.json
- webpack.config.js
- launch.json
- 文件夹结构
- 未绑定断点错误
- 控制台输出
{
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"crypto": "^1.0.1",
"debug": "~2.6.9",
"ejs": "^3.1.5",
"express": "~4.16.1",
"express-jwt": "^6.0.0",
"joi": "^17.3.0",
"joi-password-complexity": "^5.0.2",
"jsonwebtoken": "^8.5.1",
"mailgun.js": "^2.0.6",
"mongodb": "^3.6.3",
"mongoose": "^5.11.11",
"mongoose-paginate-v2": "^1.3.13",
"morgan": "^1.10.0",
"mustache": "^4.1.0",
"nodemailer": "^6.4.17",
"path": "^0.12.7",
"querystring": "^0.2.0",
"saslprep": "^1.0.3",
"swagger-ui-express": "^4.1.6",
"winston": "^3.3.3",
"winston-daily-rotate-file": "^4.5.0"
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-decorators": "^7.12.12",
"@babel/plugin-proposal-do-expressions": "^7.12.1",
"@babel/plugin-proposal-export-default-from": "^7.12.1",
"@babel/plugin-proposal-export-namespace-from": "^7.12.1",
"@babel/plugin-proposal-function-bind": "^7.12.1",
"@babel/plugin-proposal-function-sent": "^7.12.1",
"@babel/plugin-proposal-json-strings": "^7.12.1",
"@babel/plugin-proposal-logical-assignment-operators": "^7.12.1",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
"@babel/plugin-proposal-numeric-separator": "^7.12.7",
"@babel/plugin-proposal-optional-chaining": "^7.12.7",
"@babel/plugin-proposal-pipeline-operator": "^7.12.1",
"@babel/plugin-proposal-throw-expressions": "^7.12.1",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/preset-env": "^7.12.11",
"babel-cli": "^6.26.0",
"babel-loader": "^8.2.2",
"babel-preset-env": "^1.7.0",
"copy-webpack-plugin": "^7.0.0",
"eslint": "^7.17.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^7.1.0",
"eslint-import-resolver-webpack": "^0.13.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-ordered-imports": "^0.4.0",
"eslint-plugin-prettier": "^3.3.1",
"nodemon": "^2.0.7",
"nodemon-webpack-plugin": "^4.3.2",
"prettier": "^2.2.1",
"webpack": "^5.13.0",
"webpack-cli": "^4.3.1"
},
"name": "web-api-template",
"scripts": {
"build": "npx webpack --mode production",
"start-production": "npx webpack -w --mode production",
"start": "npx webpack -w --mode development"
},
"version": "0.0.0"
}
{
"configurations": [
{
"args": [],
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"env": {
"NODE_ENV": "development"
},
"name": "Launch Program",
"port": 9229,
"preLaunchTask": null,
"request": "launch",
"runtimeArgs": [
"run-script",
"start"
],
"runtimeExecutable": "npm",
"stopOnEntry": false,
"type": "node",
"sourceMaps": true,
},
],
"version": "0.2.0"
}
webpack.config.js
const CopyWebpackPlugin = require('copy-webpack-plugin');
const NodemonPlugin = require('nodemon-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: './src/app.js',
externals: {
saslprep: "require('saslprep')",
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
],
},
output: {
filename: 'app.js',
path: path.resolve(__dirname, 'dist'),
},
plugins: [
new CopyWebpackPlugin({
patterns: [
'./node_modules/swagger-ui-dist/swagger-ui.css',
'./node_modules/swagger-ui-dist/swagger-ui-bundle.js',
'./node_modules/swagger-ui-dist/swagger-ui-standalone-preset.js',
'./node_modules/swagger-ui-dist/favicon-16x16.png',
'./node_modules/swagger-ui-dist/favicon-32x32.png',
],
}),
new webpack.SourceMapDevToolPlugin({
filename: '[name].js.map',
}),
new NodemonPlugin({
nodeArgs: ['--inspect=9229'],
}),
],
resolve: {
modules: [path.resolve(__dirname, './src'), 'node_modules'],
extensions: ['.js', '.jsx', '.json'],
},
target: 'node',
};
launch.json
{
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"crypto": "^1.0.1",
"debug": "~2.6.9",
"ejs": "^3.1.5",
"express": "~4.16.1",
"express-jwt": "^6.0.0",
"joi": "^17.3.0",
"joi-password-complexity": "^5.0.2",
"jsonwebtoken": "^8.5.1",
"mailgun.js": "^2.0.6",
"mongodb": "^3.6.3",
"mongoose": "^5.11.11",
"mongoose-paginate-v2": "^1.3.13",
"morgan": "^1.10.0",
"mustache": "^4.1.0",
"nodemailer": "^6.4.17",
"path": "^0.12.7",
"querystring": "^0.2.0",
"saslprep": "^1.0.3",
"swagger-ui-express": "^4.1.6",
"winston": "^3.3.3",
"winston-daily-rotate-file": "^4.5.0"
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-decorators": "^7.12.12",
"@babel/plugin-proposal-do-expressions": "^7.12.1",
"@babel/plugin-proposal-export-default-from": "^7.12.1",
"@babel/plugin-proposal-export-namespace-from": "^7.12.1",
"@babel/plugin-proposal-function-bind": "^7.12.1",
"@babel/plugin-proposal-function-sent": "^7.12.1",
"@babel/plugin-proposal-json-strings": "^7.12.1",
"@babel/plugin-proposal-logical-assignment-operators": "^7.12.1",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
"@babel/plugin-proposal-numeric-separator": "^7.12.7",
"@babel/plugin-proposal-optional-chaining": "^7.12.7",
"@babel/plugin-proposal-pipeline-operator": "^7.12.1",
"@babel/plugin-proposal-throw-expressions": "^7.12.1",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/preset-env": "^7.12.11",
"babel-cli": "^6.26.0",
"babel-loader": "^8.2.2",
"babel-preset-env": "^1.7.0",
"copy-webpack-plugin": "^7.0.0",
"eslint": "^7.17.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^7.1.0",
"eslint-import-resolver-webpack": "^0.13.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-ordered-imports": "^0.4.0",
"eslint-plugin-prettier": "^3.3.1",
"nodemon": "^2.0.7",
"nodemon-webpack-plugin": "^4.3.2",
"prettier": "^2.2.1",
"webpack": "^5.13.0",
"webpack-cli": "^4.3.1"
},
"name": "web-api-template",
"scripts": {
"build": "npx webpack --mode production",
"start-production": "npx webpack -w --mode production",
"start": "npx webpack -w --mode development"
},
"version": "0.0.0"
}
{
"configurations": [
{
"args": [],
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"env": {
"NODE_ENV": "development"
},
"name": "Launch Program",
"port": 9229,
"preLaunchTask": null,
"request": "launch",
"runtimeArgs": [
"run-script",
"start"
],
"runtimeExecutable": "npm",
"stopOnEntry": false,
"type": "node",
"sourceMaps": true,
},
],
"version": "0.2.0"
}
文件夹结构
未绑定断点错误
控制台输出
webpack 5.13.0 compiled with 13 warnings in 8376 ms
[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): dist/app.js
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node --inspect=9229 dist/app.js`
Debugger attached.
2021-02-04 13:36:33 info: Server running on port 4000