node.js - 我无法安装请求
问题描述
我正在尝试使用 Marvel api,并打算使用 request 来拨打电话。我尝试运行 npm install request --save 并且收到了已弃用的错误消息。我将包括依赖项,然后是代码和错误
"dependencies": {
"body-parser": "^1.19.0",
"ejs": "^2.7.3",
"express": "^4.17.1",
"marvel-api": "^1.1.0",
"nodemon": "^1.19.4"
}
var express = require('express');
var app = express();
var bodyparser = require("body-parser");
var api = require('marvel-api');
/* var request = require("request"); */
var marvel = api.createClient({
publicKey: 'taken out'
, privateKey: 'taken out'
});
app.set("view engine", "ejs")
app.use(express.static(__dirname + "/public"));
app.use(bodyparser.urlencoded({extended:true}));
app.get("/", function(req,res){
marvel.characters.findByName('spider-man')
.then(function(res) {
console.log('Found character ID', res.data[0].id);
res.render("landing", {marvel:res.data[0].id});
return marvel.characters.comics(res.data[0].id);
})
.then(function(res) {
console.log('found %s comics of %s total', res.meta.count, res.meta.total);
console.log(res.data);
})
.fail(console.error)
.done();
})
npm install request --save
npm WARN deprecated hawk@3.1.3: This module moved to @hapi/hawk. Please make sure to switch over as
this distribution is no longer supported and may contain bugs and critical security issues.
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated hoek@2.16.3: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated cryptiles@2.0.5: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated boom@2.10.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated sntp@1.0.9: This module moved to @hapi/sntp. Please make sure to switch over as
this distribution is no longer supported and may contain bugs and critical security issues.
npm WARN marvel@1.0.0 No repository field.
npm ERR! code EINVAL
npm ERR! EINVAL: invalid argument, read
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Owner\AppData\Roaming\npm-cache\_logs\2019-11-19T04_17_15_173Z-debug.log
解决方案
我更新了我的 npm 和节点。之后它允许我安装请求,谢谢
推荐阅读
- json - 如何在 Pyspark 数据框中查询字典格式列
- node.js - 使用for循环nodejs验证var是否为无穷大更改变量值
- javascript - javascript jira-client 包:设置主机时如何指定端口
- ios - Xcode 只读取一些 Resource TXT 文件
- javascript - Symfony 4 - 如何使用 Javascript 删除树枝上的选择?
- wordpress - 如何在 ACF PRO LOOP 中自动增加数字
- php - 合并对象以进行动态 rethinkdb 查询
- docker - NGINX 反向代理在 JIRA 上抛出 HTTP 503
- java - RestTemplate/HttpClient 更改 Spring Boot 1.5 -> 2.1
- python - 具有重复项的键的多路合并不起作用