禁用附加的node.js调试器

3z6pesqy  于 2022-10-01  发布在  Node.js
关注(0)|答案(3)|浏览(149)

如图所示,在运行npm run dev时,我总是在vscode中附加node.js调试器。有什么方法可以禁用它吗?

我附上了package.json的内容

{
    "name": "ff-front",
    "version": "0.1.0",
    "private": true,
    "scripts": {
        "lint": "eslint src server --ext .js,.jsx",
        "lint:fix": "eslint src server --ext .js,.jsx --fix",
        "dev": "next dev",
        "build": "next build",
        "start": "next start -p 80",
        "start:pm2:next": "pm2 start server/babel.js --name ff-front",
        "stop:pm2:next": "pm2 delete ff-front",
        "deploy": "npm run stop:pm2:next; npm run build && npm run start:pm2:next"
    },
    "engines": {
        "node": ">=14.16.0"
    },
    "dependencies": {
        "@ckeditor/ckeditor5-react": "^3.0.3",
        "@material-ui/core": "^4.11.3",
        "@material-ui/icons": "^4.11.2",
        "@sosedisverhu/ckeditor5-build-classic": "^23.0.0",
        "babel-plugin-inline-react-svg": "^2.0.1",
        "body-parser": "^1.19.1",
        "body-scroll-lock": "^4.0.0-beta.0",
        "classnames": "^2.3.1",
        "compression": "^1.7.4",
        "cookie-parser": "^1.4.6",
        "cors": "^2.8.5",
        "cross-env": "^7.0.3",
        "date-fns": "^2.28.0",
        "eventemitter3": "^4.0.7",
        "express": "^4.17.2",
        "express-http-proxy": "^1.6.3",
        "formik": "^2.2.9",
        "helmet": "^4.6.0",
        "jsonwebtoken": "^8.5.1",
        "md5": "^2.3.0",
        "moment-timezone": "^0.5.34",
        "mongo-seeding": "^3.7.1",
        "mongodb-backup": "1.4.8",
        "mongodb-restore": "^1.6.2",
        "mongoose": "^6.1.3",
        "multer": "^1.4.4",
        "next": "12",
        "node-schedule": "^2.1.0",
        "nodemailer": "^6.7.2",
        "nodemon": "^2.0.15",
        "pm2": "^5.1.2",
        "prop-types": "^15.7.2",
        "ramda": "^0.27.1",
        "rctx-contextmenu": "^1.3.5",
        "react": "^17.0.2",
        "react-datepicker": "^4.6.0",
        "react-dom": "^17.0.2",
        "react-facebook-login": "^4.1.1",
        "react-google-authorize": "^1.0.4",
        "react-intl": "^5.13.2",
        "react-lazyload": "^3.2.0",
        "react-number-format": "^4.9.1",
        "react-redux": "^7.2.2",
        "react-rnd": "^10.3.5",
        "react-scroll": "^1.8.6",
        "react-select": "^5.2.2",
        "react-sortable-hoc": "^2.0.0",
        "react-sortablejs": "^6.0.0",
        "redux": "^4.0.5",
        "redux-thunk": "^2.3.0",
        "rimraf": "^3.0.2",
        "sass": "^1.49.7",
        "socket.io-client": "^4.4.1",
        "sortablejs": "^1.14.0",
        "superagent": "^6.1.0",
        "superagent-prefix": "^0.0.2",
        "tar": "^6.1.11",
        "timezones-list": "^3.0.1",
        "uniqid": "^5.4.0",
        "webp-converter": "^2.3.3",
        "yup": "^0.32.11"
    },
    "devDependencies": {
        "babel-eslint": "^10.1.0",
        "babel-preset-env": "^1.7.0",
        "babel-preset-stage-3": "^6.24.1",
        "babel-register": "^6.26.0",
        "eslint": "^7.21.0",
        "eslint-config-standard": "^16.0.2",
        "eslint-plugin-import": "^2.22.1",
        "eslint-plugin-node": "^11.1.0",
        "eslint-plugin-promise": "^4.2.1",
        "eslint-plugin-react": "^7.22.0",
        "next-fonts": "^1.5.1",
        "next-images": "^1.7.0"
    }
}

并且在package.json

中有一个调试选项

c3frrgcw

c3frrgcw1#

Visual Studio代码是附加调试器的代码。在settings.json(ctrl+,)中,搜索以下设置并将其添加到您自己的用户设置中。

要在vscode的终端中禁用附件,请执行以下操作:

// Configures which processes to automatically attach and debug when
// `debug.node.autoAttach` is on. A Node process launched with the `--inspect`
// flag will always be attached to, regardless of this setting.
//  - always: Auto attach to every Node.js process launched in the terminal.
//  - smart: Auto attach when running scripts that aren't in a node_modules folder.
//  - onlyWithFlag: Only auto attach when the `--inspect` is given.
//  - disabled: Auto attach is disabled and not shown in status bar.
"debug.javascript.autoAttachFilter": "disabled",

要在package.json中隐藏代码透镜,请执行以下操作:

// Where a "Run" and "Debug" code lens should be shown in your npm scripts.
// It may be on "all", scripts, on "top" of the script section, or "never".
"debug.javascript.codelens.npmScripts": "never",

保存设置后,您可能需要关闭终端和/或重新启动vscode。

mftmpeh8

mftmpeh82#

我错误地在VSC中按了“Run and Debug”,当我去终端时,它显示了你提到的命令,在互联网上搜索了一段时间后,我只是关闭了终端,当我第二天在一个新的终端上运行它时,它没有运行,后来我在互联网上读到,当你按一次它,VSC假设你将进行调试,这就是为什么它总是运行它。Where I unintentionally pressed.

i killed the terminal

bqucvtff

bqucvtff3#

我这样做的方式是按ctrl+狗屎+p将打开一个对话框。搜索切换自动附加,选择已禁用

当您要调试时,选择始终

相关问题