Javascript 从终端运行不会产生与从调试运行相同的结果

Javascript 从终端运行不会产生与从调试运行相同的结果,javascript,node.js,tesseract,Javascript,Node.js,Tesseract,我有以下代码 var Tesseract = require('tesseract.js') var filename = '2.jpg' Tesseract.recognize(filename) .progress(function (p) { console.log('progress', p) }) .catch(err => console.error(err)) .then(function (result) { c

我有以下代码

    var Tesseract = require('tesseract.js')
    var filename = '2.jpg'

    Tesseract.recognize(filename)
    .progress(function  (p) { console.log('progress', p)  })
    .catch(err => console.error(err))
    .then(function (result) {
    console.log(result.text)
    //getPersonName(result.text);
    process.exit();
  })
当使用命令节点ocr.js运行时,一切都运行得非常完美,我从图片中获取文本

但如果使用节点调试器从visual studio代码调试运行,则会出现以下错误:

C:\Program Files\nodejs\node.exe --inspect-brk=19996 ocr.js 
Debugger listening on ws://127.0.0.1:19996/21ca94e0-ff75-4386-8b0c-ce8342aad6af
Starting inspector on 127.0.0.1:19996 failed: address already in use
Debugger attached.
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at _errnoException (util.js:1022:11)
    at ChildProcess.target._send (internal/child_process.js:702:20)
    at ChildProcess.target.send (internal/child_process.js:586:19)
    at c:\Users\jorgem\Desktop\ocrjs2\node_modules\tesseract.js\src\node\index.js:28:25
    at loadImage (c:\Users\jorgem\Desktop\ocrjs2\node_modules\tesseract.js\src\node\index.js:96:5)
    at loadImage (c:\Users\jorgem\Desktop\ocrjs2\node_modules\tesseract.js\src\node\index.js:94:16)
at c:\Users\jorgem\Desktop\ocrjs2\node_modules\tesseract.js\src\node\index.js:48:13
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
Waiting for the debugger to disconnect...
Error: write EPIPE
util.js:1022
    at _errnoException (util.js:1022:11)
    at ChildProcess.target._send (internal/child_process.js:702:20)
    at ChildProcess.target.send (internal/child_process.js:586:19)
    at c:\Users\jorgem\Desktop\ocrjs2\node_modules\tesseract.js\src\node\index.js:28:25
    at loadImage (c:\Users\jorgem\Desktop\ocrjs2\node_modules\tesseract.js\src\node\index.js:96:5)
    at loadImage (c:\Users\jorgem\Desktop\ocrjs2\node_modules\tesseract.js\src\node\index.js:94:16)
    at loadImage (c:\Users\jorgem\Desktop\ocrjs2\node_modules\tesseract.js\src\node\index.js:83:13)
    at c:\Users\jorgem\Desktop\ocrjs2\node_modules\tesseract.js\src\node\index.js:48:13
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
我做错了什么

我的launch.json文件如下所示:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/ocr.js"
        }
    ]
}

问题解决:我们在launch.json文件中添加了两行:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",                ,
            **"port": 5859,
            "timeout": 30000,**
            "program": "${workspaceFolder}/ocr.js"
        }
    ]
}

这就解决了问题

问题解决了:我们在launch.json文件中添加了两行:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",                ,
            **"port": 5859,
            "timeout": 30000,**
            "program": "${workspaceFolder}/ocr.js"
        }
    ]
}

这就解决了问题

我注意到只有在使用visual studio代码时才需要更改超时。。。命令行没有此问题我注意到只有在使用visual studio代码时才需要更改超时。。。命令行没有这个问题