在intellij ultimate 2017.1中调试节点/ Express应用程序

时间:2017-07-10 01:05:00

标签: node.js reactjs express intellij-idea node-inspector

我正在尝试调试我的快速应用程序我已根据intellij帮助文档配置了我的IDE。但是当我运行应用程序时,进程永远不会在断点处停止。

请在下面找到我的配置窗口详细信息: enter image description here

Intellij版本:2017.1 下面是我在调试器控制台中看到的:

/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...

我的应用程序在端口8080上运行。

我错过了什么,任何指针都会有所帮助

修改:

我曾尝试使用IJ-EAP-2017.2。这在尝试调试时在控制台中给我一个新错误。

/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

我不确定为什么我们会收到此错误,仍然在努力使调试器工作。

SyntaxError: Unexpected token import
    at createScript (vm.js:53:10)

3 个答案:

答案 0 :(得分:1)

问题在于:import& Node.js尚未支持ES6的export语法。不幸的是,当前best proposal仍处于draft状态。

您可以使用的一些解决方案:

  • 解决方案1:使用Babel启用对ES6(和ES6 +)语法的完全支持。只需按照the official installation guideline即可完成操作。您还需要使用babel-node来调试ES6完整语法。
  • 解决方案2(推荐):使用require & module.exports(考虑您是否确实需要 import / export)回到过去的方向。等到Node.js正式发布对ES6的全面支持。

希望这有助于:)

答案 1 :(得分:0)

请尝试2017.2 EAP:https://www.jetbrains.com/idea/nextversion/。自2017.1以来,Node 8的一些问题已得到修复。

答案 2 :(得分:0)

从错误消息看来,您似乎正在尝试使用Node.js运行React组件。 React应用程序通常由浏览器执行,这是一个客户端代码,因此您必须构建应用程序,启动它所托管的服务器,然后使用JavaScript Debug运行配置在浏览器中对其进行调试。

有关调试反应应用的详情,请参阅https://blog.jetbrains.com/webstorm/2017/01/debugging-react-apps/

相关问题