伙计们,拜托,我无法解决这个问题,ipware,javascript和express
Posted
技术标签:
【中文标题】伙计们,拜托,我无法解决这个问题,ipware,javascript和express【英文标题】:guys, please,I can't wrap my hand around this, ipware, javascript and express 【发布时间】:2021-05-08 01:21:09 【问题描述】:所以,我正在尝试使用 express 做某事,更具体地说,我正在尝试获取用户的 ip 地址,但有些东西不起作用,我无法弄清楚出了什么问题,我确信这是一个错误,因为当我尝试通过 localhost 访问应用程序时,它对我说:
Cannot GET /
以下是控制台中出现的内容:
express app listening at http://localhost:443
cleanup_ip: [Function (anonymous)],
is_loopback_ip: [Function (anonymous)],
is_private_ip: [Function (anonymous)],
is_valid_ipv4: [Function (anonymous)],
is_valid_ipv6: [Function (anonymous)],
is_valid_ip: [Function (anonymous)],
get_headers_attribute: [Function (anonymous)],
get_local_ip: [Function (anonymous)],
get_ip: [Function (anonymous)],
get_trusted_ip: [Function (anonymous)]
这是代码:
const express = require('express');
var get_ip = require('ipware');
const app = express();
const port = 443;
app.use('/', function(req, res, next)
var ipInfo = get_ip(req);
console.log(ipInfo);
//dovrebbe stampare a console l'ip dell'utente
next();
);
app.listen( port, () =>
console.log(`express app listening at http://localhost:$port`);
);
另外,我发现了 Visual Studio 代码告诉我的一条消息,它说:
Could not find a declaration file for module 'ipware'. 'c:/Users/ascar/Desktop/programming/app.js/node_modules/ipware/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/ipware` if it exists or add a new declaration (.d.ts) file containing `declare module 'ipware';`
唯一的问题是 npm i --save-dev @types/ipware 给了我这个错误:
'@types/ipware@*' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
我不知道如何做这些事情,我希望你们能告诉我该怎么做。 请帮助伙计们!我对你们有信心
【问题讨论】:
【参考方案1】:GET /
上没有路由处理程序,您必须至少定义一个路由:
app.get("/", (req,res) => res.send("Hello"));
【讨论】:
以上是关于伙计们,拜托,我无法解决这个问题,ipware,javascript和express的主要内容,如果未能解决你的问题,请参考以下文章
嘿伙计们,我尝试将生成的 apk 上传到 Google Play 商店并不断收到此错误任何想法