Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
正在尝试使用npm start启动node.js应用程序,但在浏览器中得到err\u empty\u响应_Node.js_Npm - Fatal编程技术网

正在尝试使用npm start启动node.js应用程序,但在浏览器中得到err\u empty\u响应

正在尝试使用npm start启动node.js应用程序,但在浏览器中得到err\u empty\u响应,node.js,npm,Node.js,Npm,我从一个内部repo克隆了一个node.js应用程序,该应用程序对其他开发人员来说运行良好,但对我来说不是。这是我的第一个节点应用程序,我被要求工作,但没有线索如何调试它。在收到一系列其他错误后,我最终修复了所有问题(克隆和依赖项部分),当我执行npm启动时,我可以看到应用程序已启动,并且光标在命令提示符中闪烁,但当我尝试浏览到该路径()-我在浏览器中没有收到任何响应,除了一条消息: This page isn’t working localhost didn’t send any data.

我从一个内部repo克隆了一个node.js应用程序,该应用程序对其他开发人员来说运行良好,但对我来说不是。这是我的第一个节点应用程序,我被要求工作,但没有线索如何调试它。在收到一系列其他错误后,我最终修复了所有问题(克隆和依赖项部分),当我执行npm启动时,我可以看到应用程序已启动,并且光标在命令提示符中闪烁,但当我尝试浏览到该路径()-我在浏览器中没有收到任何响应,除了一条消息:

This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
我在控制台中没有看到任何错误。我尝试使用邮递员,收到以下消息:

Could not get any response
There was an error connecting to localhost:8000/service/.
mypackage.js中的代码如下:

"dependencies": {
"ansc-core": "^1.8.2",
"lodash": "~4.17.0",
"request": "~2.87.0",
"abcdef": "^1.6.1",
"underscore": "^1.9.1"
 },
my ansc.json(其中设置了端口号)中的代码是:

service.js中的代码是:

const $ = require('abcdefg').xxxxxx;

class Service {
constructor() {
    console.log("in service constructor");
    $.info({ service: 'up' });
}


  findAll() {
    return new Promise((resolve) => {

        resolve([]);

    });
  }
}

module.exports = Service;
routes.js中调用服务的代码是:

const Service = require('./service');
const $ = require('abcdefg').xxxxxx;

const service = new Service();

const Routes = {

getEntity(req, res) {
    service.findAll().then((items) => {
        console.log("inside getentity");
        res.send(items);
    }).catch((error) => {
        $.error(error);
        res.status(500).send(error);
    });
    }
 };

 module.exports = Routes;
最后index.js(应用程序的入口点)是:


还有其他人遇到过这个或类似的问题吗?

我犯了一个愚蠢的错误-通过将http更改为https解决了这个问题

我犯了一个愚蠢的错误——通过从http改为https解决了这个问题!
const Service = require('./service');
const $ = require('abcdefg').xxxxxx;

const service = new Service();

const Routes = {

getEntity(req, res) {
    service.findAll().then((items) => {
        console.log("inside getentity");
        res.send(items);
    }).catch((error) => {
        $.error(error);
        res.status(500).send(error);
    });
    }
 };

 module.exports = Routes;
  const ansc = require('ansc-core');
  const routes = require('./src/service/routes');

 ansc.routes((app) => {
  console.log("before app get");
  app.get('/service', routes.getEntity);
 }).start();

module.exports = ansc;