Error: Cannot find module 'cors'

后端 未结 4 1464
无人及你
无人及你 2021-02-19 00:07

I keep getting this error message below: I tried to find other stackoverflow post and articles but couldn\'t really sovle it. do any of you guys know what the problem is it?

相关标签:
4条回答
  • 2021-02-19 00:39

    You can simply open the package.json file in any text editor and add cors under dependencies like this: "cors": "2.8.5"

    Since the latest version of cors is 2.8.5

    0 讨论(0)
  • 2021-02-19 00:42

    Need to install cors library. Use terminal and run "npm install cors" then use below in server.js file:

    var express = require('express')
    var cors = require('cors')
    var app = express()
    app.use(cors())
    

    Or, refer link: https://www.npmjs.com/package/cors

    Thanks,

    0 讨论(0)
  • 2021-02-19 00:47

    Run npm install cors --save from the command line in the main project directory to install it and add it to your package.json

    It is possible that the cors module was separated from the main express package a long time ago, and the code you are using was written before that. (Or never was a part of it, to begin with)

    0 讨论(0)
  • 2021-02-19 00:51

    Try running npm link cors and then run npm install

    0 讨论(0)
提交回复
热议问题