gpt4 book ai didi

javascript - 类型错误 : Cannot read property 'reduce' of undefined when using ftp-deploy

转载 作者:行者123 更新时间:2023-11-30 11:16:56 26 4
gpt4 key购买 nike

我正在尝试使用 ftp-deploy当然要将一些文件部署到 ftp 服务器。我的文件如下所示:

部署.js

var FtpDeploy = require("ftp-deploy");
var ftpDeploy = new FtpDeploy();

var config = {
user: "myusername",
password: "mypassword",
host: "myipaddress",
port: 21,
localRoot: __dirname + "/",
remoteRoot: "/public_html/",
include: ["index.html", "index.css", "assets/*"],
deleteRoot: true
};

ftpDeploy
.deploy(config)
.then(res => console.log("Deployed successfully!"))
.catch(err => console.log(err));

当我运行 yarn deploy 时,出现以下错误:

Connected to: myipaddress
Connected: Server message: --------- Welcome to Pure-FTPd [privsep] [TLS] ----------
You are user number 2 of 50 allowed.
Local time is now 08:43. Server port: 21.This is a private system - No anonymous login
IPv6 connections are also welcome on this server.
You will be disconnected after 15 minutes of inactivity.
Failed undefined
TypeError: Cannot read property 'reduce' of undefined
at canIncludePath (/Users/dean/Desktop/website/node_modules/ftp-deploy/src/lib.js:53:31)
at handleItem (/Users/dean/Desktop/website/node_modules/ftp-deploy/src/lib.js:79:17)
at Array.reduce (<anonymous>)
at parseLocal (/Users/dean/Desktop/website/node_modules/ftp-deploy/src/lib.js:102:23)
at handleItem (/Users/dean/Desktop/website/node_modules/ftp-deploy/src/lib.js:68:23)
at Array.reduce (<anonymous>)
at Object.parseLocal (/Users/dean/Desktop/website/node_modules/ftp-deploy/src/lib.js:102:23)
at FtpDeployer.checkLocalAndUpload (/Users/dean/Desktop/website/node_modules/ftp-deploy/src/ftp-deploy.js:86:27)
at lib.checkIncludes.then.then.then.then.config (/Users/dean/Desktop/website/node_modules/ftp-deploy/src/ftp-deploy.j
s:109:34)
at tryCatcher (/Users/dean/Desktop/website/node_modules/ftp-deploy/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/dean/Desktop/website/node_modules/ftp-deploy/node_modules/bluebird/js/re
lease/promise.js:512:31) at Promise._settlePromise (/Users/dean/Desktop/website/node_modules/ftp-deploy/node_modules/bluebird/js/release/promi
se.js:569:18)
at Promise._settlePromise0 (/Users/dean/Desktop/website/node_modules/ftp-deploy/node_modules/bluebird/js/release/prom
ise.js:614:10) at Promise._settlePromises (/Users/dean/Desktop/website/node_modules/ftp-deploy/node_modules/bluebird/js/release/promise.js:693:18) at Async._drainQueue (/Users/dean/Desktop/website/node_modules/ftp-deploy/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/Users/dean/Desktop/website/node_modules/ftp-deploy/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/Users/dean/Desktop/website/node_modules/ftp-deploy/node_modules/bluebird/js/release/
async.js:17:14)
at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
at processImmediate [as _immediateCallback] (timers.js:722:5)
✨ Done in 0.54s.
deans-imac:website dean$

这是我做错了什么还是他们的包裹有错误?

最佳答案

查看 ftp-deploy 的源代码,看起来 exclude 可能是必需的配置项。看起来他们正在调用 reduce 而没有测试它是否存在。我会尝试在配置中添加一个空的 exclude: [] ,看看是否有帮助。

var config = {
user: "myusername",
password: "mypassword",
host: "myipaddress",
port: 21,
localRoot: __dirname + "/",
remoteRoot: "/public_html/",
include: ["index.html", "index.css", "assets/*"],
exclude: [], // <-- add this
deleteRoot: true
};

关于javascript - 类型错误 : Cannot read property 'reduce' of undefined when using ftp-deploy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51204456/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com