如何摆脱 Connect 3.0 弃用警报? [英] How to get rid of Connect 3.0 deprecation alert?

查看:24
本文介绍了如何摆脱 Connect 3.0 弃用警报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名 node.js 开发人员,使用 express.js 创建 Web 应用程序.到目前为止,我的问题是:

I'm a node.js developer who creates web apps using express.js. By now, my problem is:

每当我在我的计算机上创建一个应用程序时,npm 安装它的东西并运行它(使用 node app.js 和 nodemon)我在控制台中收到此消息:

Whenever I create an app on my computer, npm install its stuff and run it (with node app.js and nodemon) I get this message in the console:

connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
Express server listening on port 3000

该应用程序正常运行,没问题.但是,当我克隆在其他计算机上创建的应用程序时,我没有收到该消息,所以我假设我的计算机中有一些过时的东西.

The app works, that's fine. But when I clone an app created in other computer I don't get that message, so I'm supposing I have something outdated in my computer.

我去了消息中提到的网站,证实了我的猜测.这是一个弃用警告.但是,我已经更新了 node 和 npm 以及 global express,但我仍然收到了注释.

I went to the site mentioned in the message and confirmed my speculations. That is a deprecation warning. However, I've updated node and npm and globally express but I still getting the note.

因此,我的问题是:我不知道我需要更新什么才能摆脱弃用注释,因为它们让我感到害怕.

My problem is, therefore: I don't know what do I need to update in order to get rid of the deprecation notes because they're freaking me out.

我希望有人能帮助我.非常感谢.

I hope someone can help me. Thanks a lot.

推荐答案

这是一个警告,一旦 Express 更新为使用 Connect 3.0,此警告就会消失 - 作为临时修复,请按照 https://github.com/senchalabs/connect/wiki/Connect-3.0.具体来说,在您的应用中找到这一行:

This is a warning that will go away once Express updates to use Connect 3.0 - as a temporary fix, follow the instructions at the top of https://github.com/senchalabs/connect/wiki/Connect-3.0. Specifically, find this line in your app:

app.use(express.bodyParser());

并将其替换为以下内容(这是 bodyParser 在 3.0 中的内容):

And replace it with the following (this is what bodyParser will be in 3.0):

app.use(express.json());
app.use(express.urlencoded());

这篇关于如何摆脱 Connect 3.0 弃用警报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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