程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了当我在 apt.get()大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决当我在 apt.get()?

开发过程中遇到当我在 apt.get()的问题如何解决?下面主要结合日常开发的经验,给出你关于当我在 apt.get()的解决方法建议,希望对你解决当我在 apt.get()有所启发或帮助;

我试图在 NodeJs 服务器上的 app.get() 期间从 IBM Watson 获取信息。从 Watson 获取信息的代码有效,我正在努力将其发送回客户端。 但是每当我添加额外的 console.print( words ) 时,它都会吓坏并抱怨在我添加新的 console.print() 语句之前完全不同的行。

app.get("/text/emotion",(req,res) => {
    const nlu = getNLUInstance();
    //console.log( "request /text/emotion");
    var parameters = { text: "I am having a bad day today,\
        Could someone Help me please",features : {emotion: {}}}
    ret = nlu.analyze( parameters ) //,function( error,responsE){
           .then (analysisResults => {
            console.log(JsON.Stringify(analysisResults,null,2));
            console.log( "in here")
           })
           .catch(err=> {Console.log( "error",err);
           });
          
  
    console.log( ret );
    return res.send({"happy":"10","sad":"50"});
});

app.get("/text/sentiment",res) => {
    return res.send("text sentiment for "+req.query.text);
});

let server = ***app.Listen(8080,()*** => {
    console.log('Listening',server.address().port);
});

这有效,但如果我在 console.log(ret) 上方添加另一个 console.log("Here") 语句,它会担心 app.Listen(8080... 调用。错误指向 app.Listen 之间的点“.”

所以代码不起作用

    console.log( "here"); 
    console.log( ret );
    return res.send({"happy":"10","sad":"50"});
});

但是这段代码可以

    console.log( ret );
    return res.send({"happy":"10","sad":"50"});
});

这是添加额外的console.log()时的错误输出

[nodemon] starTing `node sentimentAnalyzerServer.Js`
events.Js:292
      throw er; // Unhandled 'error' event
      ^

Error: Listen EADDRINUSE: address already in use :::8080
    at Server.setupListenHandle [as _Listen2] (net.Js:1313:16)
    at ListenInCluster (net.Js:1361:12)
    at Server.Listen (net.Js:1447:7)
    at Function.Listen (/home/project/cazgi-IBM-Watson-NLU-Project-1/sentimentAnalyzeServer/node_modules/express/lib/application.Js:618:24)
    at Object.<anonymous> (/home/project/cazgi-IBM-Watson-NLU-Project-
1/sentimentAnalyzeServer**/sentimentAnalyzerServer.Js:64:18)**
    at Module._compile (internal/modules/cJs/loader.Js:1137:30)
    at Object.Module._extensions..Js (internal/modules/cJs/loader.Js:1157:10)
    at Module.load (internal/modules/cJs/loader.Js:985:32)
    at Function.Module._load (internal/modules/cJs/loader.Js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.Js:71:12)
Emitted 'error' event on Server instance at:
    at emitErrorNT (net.Js:1340:8)
    at processticksAndRejections (internal/process/task_queues.Js:84:21) {
  code: 'EADDRINUSE',errno: 'EADDRINUSE',syscall: 'Listen',address: '::',port: 8080
}
[nodemon] app crashed - waiTing for file changes before starTing...

看来,不管我把额外的console.log 语句,它只是不喜欢它们。 或者有没有更好的方法来调试这些东西。我正在使用终端来完成所有这些。 我对 Node.Js 和 JavaScript 很陌生,但这对我来说似乎不合适。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

大佬总结

以上是大佬教程为你收集整理的当我在 apt.get()全部内容,希望文章能够帮你解决当我在 apt.get()所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:当我在