You can take a look at the complete configuration of the Angular + Sails starter, for debugging a Sails app.
The following steps describe how to set up the package.json scripts to start debugging with a single command from the console,
- Open a terminal and go to sails directory.
- First, we need to run node with "--inspect" flag to inspect the code inside chrome's DevTools. So we need to run,
node --inspect app.js
To get sails up and running.
However, we might be missing webpack dev-server or any other middleware process.
- Modify package.json's scripts adding the following lines,
"start:debug" : "npm-run-all --parallel open:client debug", ... "debug": "node --inspect app.js"
The complete scripts sections looks like this,
"start": "npm-run-all --parallel open:client dev", "start:debug" : "npm-run-all --parallel open:client debug", "open:client" : "ng serve --open", "build": "npm run build:prod", "build:dev": "ng build --deploy-url=dist", "build:prod": "ng build --prod --deploy-url=dist", "build:aot": "ng build --aot --deploy-url=dist", "clean": "rimraf assets/dist", "prod": "sails lift --prod", "dev": "sails lift --dev", "debug": "node --inspect app.js"
This way, we can just run "npm run start:debug" and run Sails normally as we usually do but featuring debugging.
You should see something like the following,
It prompts you to open the long URL chrome-devtools://... in the browser but doesn't. Instead open "about:inspect" in Chrome
Click on Open dedicated DevTools for Node to open a new DevTools window,
That's it!. Now you can debug Sails.js in Devtools!.