无法启动“curl:localhost:3000”端口,显示 URI 错误

维维克·帕塔奈克

我刚刚开始使用 node js,特别是启动一个服务器,并尝试一个新的应用程序来修剪一个 URL。但我被困在这里。

环境:窗户

文本编辑器:VSCode

我的 index.js 代码:

/*
* Primary file for the API
*
*/
// Dependencies

var http = require('http');
var url = require('url');

// The Server shoudl respond to all requests with a string
var server = http.createServer(function (req, res) {
    // Get URL and Parse it
    var parsedUrl = url.parse(req.url, true);

    //Get the Path
    var path = parsedUrl.pathname;
    var trimmedPath = path.replace(/^\/+|\/+$/g, '');

    //Send the Response
    res.end('Hello World!\n');

    //Log the requst path
    console.log('Request recieved on path: ' + trimmedPath);

});

// Start the server, and have it listen on port 3000
server.listen(3000, function () {
    console.log("The server is listening on port 3000 now");
});

在此之后,我使用命令启动服务器

node index.js

它启动服务器,然后我打开另一个终端并输入

curl localhost:3000

它给了我以下错误

curl : The URI prefix is not recognized.
At line:1 char:1
+ curl localhost:3000
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotImplemented: (:) [Invoke-WebRequest], NotSupportedException
    + FullyQualifiedErrorId : WebCmdletIEDomNotSupportedException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
金金

不要curl单独使用而是添加http到 URL 以查看此类内容:-

curl http://localhost:3000(你可以使用你的端口号)

注意:https不是首选

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

反应代理错误:无法将请求/ api /从localhost:3000代理到http:// localhost:8000(ECONNREFUSED)

发送邮件错误,javax.mail.MessagingException:无法连接到SMTP主机:localhost,端口:25;

Artisan错误:无法在localhost:8000上监听

无法使用Rails ping http:// localhost:3000

Mongodb错误:无法连接到[localhost:27017]

ElasticSearch安装错误-curl:(7)无法连接到localhost:9200; 拒绝连接

Puma错误:无法分配请求的地址-为“ 10.0.2.2”端口3000(Errno :: EADDRNOTAVAIL)绑定(2)

在Procfile中运行时tcp:// localhost:3000:5000(URI :: InvalidURIError)

Cloudflare Api v4 php Curl-错误方法POST无法用于该URI

无法在localhost:3000上获取/

错误:类型不兼容:Task <Uri>无法转换为Uri

如何解决“未处理的承诺拒绝:错误:无法解析来自http:// localhost:3000 /的裸指定符“ app.js”

GStreamer; 无法播放错误:“无效的URI \“ \”。

代理错误:无法将请求/付款从localhost:3000代理到https:// localhost:5000 /

无法在node.js应用程序中运行localhost:3000,错误:无法在视图目录“ ./views”中查找视图“ home”

每次重新启动npm run dev时,端口3000已在使用中出现错误

间歇性错误:无法打开显示:localhost:10.0与Vagrant

添加GPG密钥的'无效的HTTP代理(http:// localhost:4001):错误的URI'错误

Android SipProfile Uri UDP端口错误

错误:Azure VM无法获取结构URI

当我尝试将端口3000用于HTTP并将端口443用于HTTPS时,它显示错误错误:绑定EACCES

解析的Uri端口号错误

无法访问 http://localhost:3000/

AWS Lambda 返回错误,而 localhost 显示结果

代理错误:无法将请求 /users 从 localhost:3000 代理到 http://localhost:3001/

Jmeter 显示错误:无法创建 PoolableConnectionFactory(用户 'shubham@localhost'@'118.185.61.226' 的访问被拒绝(使用密码:YES))

在 Angular 中 POST http://localhost:3000/auth 400(错误请求)

代理错误:无法将请求 /api/house-listing 从 localhost:3000 代理到 http://localhost:5000?(ECONNRESET), MERN

启动 Spring 项目时,端口 http://localhost:8080/ 上会显示登录屏幕