快递没有定义... ??即使安装后

时间:2018-07-07 23:21:52

标签: node.js express

package.json下的我的代码

{
  "name": "mernstack",
  "version": "1.0.0",
  "description": "social network for developers",
  "main": "server.js",
  "scripts": {
    "start": "node server.js",
    "server": "nodemon server.js"
  },
  "author": "sonali",
  "license": "MIT",
  "dependencies": {
    "bcrypt": "^2.0.1",
    "bcryptjs": "^2.4.3",
    "express": "^4.16.3",
    "gravatar": "^1.6.0",
    "mongoose": "^5.1.6",
    "passport": "^0.4.0",
    "passport-jwt": "^4.0.0",
    "validator": "^10.4.0"
  },
  "devDependencies": {
    "eslint": "^4.19.1",
    "nodemon": "^1.17.5"
  }
}

即使它之前运行得很好,我也收到此错误...?收到此错误后,我已经在那时重新安装了Express,在收到该错误后,它显示了字节错误,我已经卸载了npm并重新安装了它,之后,我得到了此错误,请帮帮我

2 个答案:

答案 0 :(得分:0)

如果我们能看到您的代码,会更容易,但是您初始化正确吗?

const express = require('express');
const app = express();

答案 1 :(得分:0)

您必须在应用程序中实例化快递

const express = require('express');
const app = express();

或者如果您使用的是新导入

import express from 'express';