debug nodejs with nodemon and intellij

Noticed that if I run nodemon within intellij, I would not be able to debug any more inside intellij.
Not sure what reason it is. If just run the nodejs, no problem. However once I add the ‘/usr/local/bin/nodemon’ into the Node parameters of the run config, the breakpoint would not work.

solution

To solve this problem, i have to use the Node.js remote debug.
Steps are

1. add a debug port to the Node parameters

–debug=3001. Note It is double dash. this should be the same as the port in the following remote debug config.

in the intellij doc, another option is to use –debug-brk which would enable the debug to run from the start. I tried this param, it works if I just change some front end html/js, however it would not work when backend js changed. Might have other workaround if you have to debug some init processes.

debug config intellij nodejs

debug config intellij nodejs

2. add a new Node.js remote debug config in Intellij

remote debug intellij node

remote debug intellij node

Now you should be able to use run RUN to start the server.js application and use DEBUG to start the ‘remote server debug’ and then set break point in your node app. 🙂

Advertisements

add google code as a remote in git for intellij

add remote for intellij

I use intellij to create a local git repo.

To add a new remote:

1. create a project in google code.

2. go to this link: https://code.google.com/hosting/settings. Copy the

machine code.google.com login xxxxx@gmail.com password xxxxxxxxx 
to the user directory’s .netrc file: ~/.netrc
then change the priv for this file, could be 500/600, i use 600
chmod 600 .netrc
 
3. go to the project root(where you create the git local repo). use;

git remote add googlecode https://code.google.com/p/xxxxxx/

this will add google code as your remote.

To verify the remote:

git remote -v

4. now you can go to intellij VSC->git-> push to push change to your remote. Or just use command line: git push googlecode HEAD

About git remote add and push .. master

  1. What is git remote add ...As you probably know, git is a distributed version control system. Most operations are done locally. To communicate with the outside world, git uses what are called remotes. These are repositories other than the one on your local disk which you can push your changes into (so that other people can see them) or pull from (so that you can get others changes). The command git remote add origin git@github.com:peter/first_app.gitcreates a new remote called origin located at git@github.com:peter/first_app.git. Once you do this, in your push commands, you can push to origin instead of typing out the whole URL.
  2. What is git push origin masterThis is a command that says “push the commits in the local branch named master to the remote named origin“. Once this is executed, all the stuff that you last synchronised with origin will be sent to the remote repository and other people will be able to see them there.

Intellij source code config

If you have a jar which contains both source and compiled class file, you tend to not be able to navigate to the source but the compiled file every time.

Or

you have a source jar but the naming is convention is not strictly followed the jar-source.jar pattern. You might also not be able to navigate to the source

To solve this problem, we need to go to the project settings -> modules and pick you module and problematic dependency and fix the red part.:

intellij-source

intellij useful shortcuts

Remember these two keyboard shortcuts

If all else fails remember:

  • Double Shift: Search everywhere. And I really mean everywhere. Even settings.

    Shift Everywhere

  • Cmd+Shift+A: Can’t remember a keyboard shortcut or menu entry? Start looking for it

    Cmd+Shift+A

FROM HERE

intellij junit working directory

if the working directory for junit test is not properly set, the resource file might not be able to be loaded if relative path is used.

By default, Intellij uses project path as working directory. However if you have sub-modules which are in the sub directories, the junit test might have problem running locally.

To set it, go to the run/debug config and select the junit, you should be able to see the ‘working directory’ option there.

To set default, go to the run/debug config, click ‘default’ and select junit, in the ‘working directory’,set ‘$MODULE_DIR$

run bat from intellij

External tools

The External Tools feature allows you to:

  • add custom menu items to run external programs, scripts, .bat files, etc.
  • parametrize custom commands with a rich set of macros, such as path to the currently opened file in the editor, project classpath, project output path, etc.
  • assign custom shortcuts to the most frequently used external tools

 

It is under: IDE settings -> external tool

 

This page shows the detail of the options.

checkin code to branch in intellij

  1. update project with “branch URL” under VCS -> update project… OR ctrl + T.  Check the below checkbox
    Update/Switch to specific Url
    • Select this check box to synchronize your local working copy with a specific repository. Specify the source repository either in the URL text box through its full Url address or in the Use Branch text box through the branch name.
    • Clear this check box to bring the changes from the repository that corresponds to the current working copy.
  2. after files are synced with branch code, do commit .

 

It is somewhat odd that intellij put this option under update project. Personally I like the “switch” command in tortoise SVN.