node-inspector

'require' is not defined in console tab of node-inspector's repl

末鹿安然 提交于 2021-02-07 14:26:38
问题 I tried to require('fs').writeFileSync('o.json', JSON.stringify(anObject)); for debugging, and I got RefrenceError: require is not defined. This is bizarre. What kind of an environment is it that doesn't have require ? 回答1: In Node.js, the require function is not defined globally. When you require a module, its source code is wrapped by a function that takes several arguments and require is one of them: (function (exports, require, module, __filename, __dirname) {/* your code */ }); You can

'require' is not defined in console tab of node-inspector's repl

南笙酒味 提交于 2021-02-07 14:22:25
问题 I tried to require('fs').writeFileSync('o.json', JSON.stringify(anObject)); for debugging, and I got RefrenceError: require is not defined. This is bizarre. What kind of an environment is it that doesn't have require ? 回答1: In Node.js, the require function is not defined globally. When you require a module, its source code is wrapped by a function that takes several arguments and require is one of them: (function (exports, require, module, __filename, __dirname) {/* your code */ }); You can

Why won't localhost route to 127.0.0.1 in chrome (OSX)?

梦想的初衷 提交于 2020-01-01 15:47:08
问题 When I launch a script using node-debug, it attempts to navigate to the URL localhost/debug?port=5858 but does not find a page served there. If I change the "localhost" to 127.0.0.1 everything works fine. I can ping localhost and it resolves appropriately to 127.0.0.1 Any ideas? 回答1: localhost has an IPv6 address (::1) as well as an IPv4 address (127.0.0.1). My guess is that your web server is only serving over IPv4, and chrome is preferring the IPv6 address. $ dscacheutil -q host -a name

Debugging karma-jasmine tests with node-inspector

本小妞迷上赌 提交于 2020-01-01 10:47:10
问题 Almost the same question as Debugging jasmine-node tests with node-inspector BUT does anyone know how to use node-inspector with karma? 回答1: Install the node-inspector globally from NPM: npm install -g node-inspector Then start the node-inspector and background the process (use fg to bring it back to the foreground and kill %1 to stop it): node-inspector & And then start your test runner like in debug mode this node --inspect ./node_modules/karma/bin/karma start Then connect to the inspector

how to debug nodeunit using node-inspector

放肆的年华 提交于 2019-12-31 21:33:53
问题 I can do: I can test node.js modules using nodeunit. I can debug my node.js express site using node inspector. But how to debug nodeunit test using node inspector? I tried, but not working: nodeunit --debug myNodeUnitModule_test.js It's not working. I tried to install nodebug. And used it like this: nodebug /usr/local/bin/nodeunit myNodeunit_test.js But it's not working neither on ubuntu ( No such file or directory ) nor on mac ( env: node\r: No such file or directory ) Almost works node -

Chrome console doesn't work for variables in node-inspector browser UI. How to enable?

谁说我不能喝 提交于 2019-12-24 01:23:38
问题 Steps to reproduce. Filename is index.js and its contents: 'use strict'; debugger; let a = 10; // doesn't mean anything in regards to the issue. Run node-debug against the file. $ node-debug index.js Node Inspector v0.12.8 Visit http://127.0.0.1:8080/?port=5858 to start debugging. Debugging `index.js` Debugger listening on [::]:5858 It opens UI in Chrome and the execution is stopped on debugger line. Set a watch variable process in a Watch Expression section. It is possible to examine it

In debug mode, mocha doesn't stop on debugger statements in a spec file when using node-inspector

跟風遠走 提交于 2019-12-23 19:39:25
问题 When I run mocha with --debug-brk and open chrome dev tools with node-inspector, the debugger skips over any debugger statements that I put in my specfile. I can get debugger statements to work in module files provided I follow this trick of placing a breakpoint at the bottom of the mocha lib. Has anybody else seen this problem? 回答1: It seems that everybody should be seeing the same problem with node-inspector version 0.2.0beta4. The problem is in the way how breakpoints are managed: The

How to setup node-inspector with vagrant?

好久不见. 提交于 2019-12-23 04:04:13
问题 I have an meanjs application running on a vagrant box. My vagrantfile is as follows config.vm.network "forwarded_port", guest: 27017, host: 27016 #mongodb config.vm.network "forwarded_port", guest: 1337, host: 1338 #node inspector config.vm.network "private_network", ip: "192.168.33.10" node inspector configuration is as follows 'node-inspector': { custom: { options: { 'web-port': 1337, 'web-host': 'localhost', 'debug-port': 5858, 'save-live-edit': true, 'no-preload': true, 'stack-trace-limit