http is not recognized in the Node Express project

0

My project is giving this error message;

Whyismyprojectnotrecognizingmyhttp?

I'mnew,andI'mstilllearningtoprograminnodeexpress.

Thisismypackage.json;

{"name": "registre",
  "version": "1.0.0",
  "description": "API",
  "main": "server/server.ts",
  "scripts": {
    "start": "./node_modules/.bin/ts-node/ ./server/server.ts",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Wladimir",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.18.3",
    "express": "^4.16.3",
    "http": "0.0.0",
    "morgan": "^1.9.0",
    "pg": "^7.4.3",
    "sequelize-cli": "^4.1.1"
  },
  "devDependencies": {
    "@types/body-parser": "^1.17.0",
    "@types/express": "^4.16.0",
    "@types/morgan": "^1.7.35",
    "@types/sequelize": "^4.27.25",
    "sequelize": "^4.38.0",
    "ts-node": "^7.0.1"
  }
}
    
asked by anonymous 26.08.2018 / 17:49

2 answers

1

As discussed in chat, problem in the standard package version of express. You made the installation of the package compatible with the @types version.

npm install @type/express current version of @types [email protected]

npm install [email protected]

Problem solved.

    
26.08.2018 / 19:43
1

As far as I know, you have two options:

  • (Recommended) Install dependency on @ types / node with npm install @types/node --save-dev .
  • Create a index.d.ts file by declaring a pro module definition http. The file looks like this: declare module 'http
  • Remember that this second option will not add auto complete with the module methods.

        
    26.08.2018 / 19:35