我正在尝试调试我的 express 应用程序 我已经根据 intellij 帮助文档配置了我的 IDE。但是当我运行该应用程序时,该过程永远不会在断点处停止。
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)
最佳答案
问题来了:ES6 的 import
& export
语法还没有被 Node.js 支持。当前best proposal不幸的是,仍处于 draft
状态。
您可以使用的一些解决方案:
- 解决方案 1:使用 Babel启用对 ES6(和 ES6+)语法的全面支持。关注the official installation guideline即可完成它。您还需要使用 babel-node能够调试 ES6 完整语法。
- 解决方案 2(推荐):通过使用
require & module.exports
回到过去的好方法(考虑您是否真正需要import/export
)。等到 Node.js 正式发布对 ES6 的全面支持。
希望这可以帮助:)
关于node.js - 在 intellij ultimate 2017.1 中调试 Node/Express 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45002483/