william007
william007

Reputation: 18547

Disable node.js debugger attached

As can be seen in the image, I always get node.js debugger attached in vscode when run npm run dev is there a way to disable that? enter image description here

I attached the content of 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"
    }
}

and there is a debug option in package.json enter image description here

Upvotes: 5

Views: 5824

Answers (4)

May T
May T

Reputation: 23

Can you see "Powershell" & "javascript Debug Terminal" on the right side of the teminal. just click on powershell, then run your code :)

you are running code within the debugger.

You can even delete and re add the debugger from this right side as well :)

My terminal example :)

Upvotes: 1

Alpha
Alpha

Reputation: 1467

The way I do this is by Press ctrl+shit+p a Dialog will open. Search Toggle Auto Attach and select Disabled.

When you want to debug select Always.

Upvotes: 7

By mistake I pressed "Run and Debug" in VSC and when I went to the Terminal, it showed the commands you mention, after a while of searching the internet, I just closed the Terminal and when I ran it the next day in a new Terminal, it didn't run , later I read on the internet that when you press it once, VSC assumes that you will be doing debugging and that's why it always runs it. Where I unintentionally pressed.

i killed the terminal

Upvotes: 1

Mark G
Mark G

Reputation: 2216

Visual Studio Code is the one attaching the debugger. In settings.json (ctrl+,), search for the following settings and add them to your own user settings.

To disable attachment in vscode's terminal:

// 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",

To hide code lens in your 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",

You may need to kill the terminal and/or restart vscode after saving your settings.

Upvotes: 9

Related Questions