Debug Node / Express app in intellij ultimate 2017.1
I am trying to debug my express application. I configured my IDE based on intellij reference documentation. But when I start the application, the process never stops at breakpoints.
Below you will find information about my configuration window:
Intellij version: 2017.1 Below I see that in the debugger console:
/Users/xxxxx/.nvm/versions/node/v8.1.2/bin/node --inspect-
brk=64692 /Users/xxxxx/Documents/WORKSPACE/acme-
web/services/acme.js
Debugger listening on ws://127.0.0.1:64692/453107ba-002c-4066-9b4c-
531e111aec87
For help see https://nodejs.org/en/docs/inspector
Debugger attached.
Waiting for the debugger to disconnect...
My application is running on port 8080.
I missed anything, any pointers would be helpful
Edit:
I tried using IJ-EAP-2017.2. This gives me a new error in the console while trying to debug.
/Users/user-xxxx/.nvm/versions/node/v8.1.2/bin/node --inspect-brk=55169 /Users/user-xxxx/Documents/WORK/acme-prj-web/src/common/pages/yyyyPage.js
Debugger listening on port 55169.
Debugger attached.
/Users/user-xxxx/Documents/WORK/acme-prj-web/src/common/pages/yyyyPage.js:1
(function (exports, require, module, __filename, __dirname) { import React, { Component, PropTypes } from "react";
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
Waiting for the debugger to disconnect...
Process finished with exit code 1
I'm not sure why we are getting this error, still trying to get the debugger to work.
SyntaxError: Unexpected token import
at createScript (vm.js:53:10)
source to share
Here's the problem: import
and export
ES6 syntax is still not supported by Node.js. The current best offer is still in status draft
.
Some solutions you can use:
- Solution 1: Use Babel to enable full ES6 (and ES6 +) syntax support. Just follow the official installation guide to do it. You also need to use babel-node to be able to debug the full ES6 syntax.
- Solution 2 (recommended): Revert to the old path using
require & module.exports
(think if you really needimport / export
). And wait until Node.js officially provides full ES6 support.
Hope this can help :)
source to share
Please try 2017.2 EAP: https://www.jetbrains.com/idea/nextversion/ . Some issues with Node 8 have been fixed since 2017.
source to share
From the error message, it sounds like you are trying to run your React component using Node.js. Reactive applications are usually executed by the browser, it is client-side code, so you need to create the application, start the server that hosts it, and then debug it in the browser using JavaScript Debug to do the configuration.
For more information on debugging React apps see https://blog.jetbrains.com/webstorm/2017/01/debugging-react-apps/
source to share