我正在尝试使用ftp-deploy将某些文件部署到ftp服务器。我的文件如下:
deploy.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$
这是我做错了还是他们的包装中存在错误?
答案 0 :(得分:3)
在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
};