Npm package sails hook debug with Webstorm

2019-09-16 08:13发布

问题:

So...
I got this npm package I'm developing for the sails framework.
The NPM package is:

https://github.com/stuk88/ecobill-hook-cms

Its loaded as a hook in sails. what is the best way to debug the package with breakpoints inside Webstorm?

回答1:

Steps:

  1. Go to Run>Edit configurations
  2. Click on (+) and pick Node.js
    1. Select one node interpreter in case is emtpy
    2. set your working directory
    3. Javascript file must be app.js in the same working directory
    4. application parameters (I usually set --dev)
    5. Environment Variables (whatever you want there)
  3. Save (Ok button)
  4. Set some breakpoints within your modules
  5. In the left top corner, just pick your configuration and click on the Debug icon.

That's all. It works for me.

Webstorm: 2016.3.1



回答2:

Ok
So the answer to that is to git clone the hook project to some other folder, and then link that folder to a folder insides /api/hooks/%hook_name%

To make a link in Windows 10, use this command (In Admin CMD): mklink /d c:\target c:\source (Not shure about the attributes order, check it out in --help)

Then the debugging will work like a charm.