错误:找不到模块“ cors” [英] Error: Cannot find module 'cors'

查看:840
本文介绍了错误:找不到模块“ cors”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在下面收到此错误消息:
我试图找到其他stackoverflow帖子和文章,但无法真正解决它。
你们有谁知道这是什么问题吗?

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?

`kimeric@pal-nat186-87-17  ~/Desktop/cs390/Assignment9/backEnd  master ✚ ● ?  node server9.js
module.js:472
    throw err;
    ^

Error: Cannot find module 'cors'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/kimeric/Desktop/cs390/Assignment9/backEnd/server9.js:11:12)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)`


推荐答案

在主项目目录的命令行中运行 npm install cors --save 进行安装并将其添加到package.json

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

很可能很久以前,cors模块已经与主要的Express包分开了,而您使用的代码是在此之前编写的。 (或者从不参与其中)

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)

这篇关于错误:找不到模块“ cors”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆