Error: Cannot find module '/home/circleci/project/.circleci/deploy.js' - CircleCI

Error: Cannot find module '/home/circleci/project/.circleci/deploy.js' - CircleCI

我试图使用 CircleCI 将我的主分支文件部署到 FTP 服务器(cpanel、apache)。我正在按照说明描述 here in this article.

但我在 "node .circleci/deploy.js"

上遇到错误

这是完整的错误日志:

#!/bin/bash -eo pipefail node .circleci/deploy.js internal/modules/cjs/loader.js:605
    throw err;
    ^

Error: Cannot find module '/home/circleci/project/.circleci/deploy.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
    at executeUserCode (internal/bootstrap/node.js:342:17)
    at startExecution (internal/bootstrap/node.js:276:5)
    at startup (internal/bootstrap/node.js:227:5)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3) Exited with code 1

这是我在“.circleci”文件夹中的 config.yml 和 config.js 文件。

version: 2
jobs:
   build:
     docker:
       - image: circleci/node:latest
     steps:
       - checkout
       - run: npm install
       - run: node .circleci/deploy.js
       - run: echo "WE'RE ONLINE"

workflows:
  version: 2
  deploy:
    jobs:
      - build:
          filters:
            branches:
              only:
                - master

Config.js 文件

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

var config = {
    username: process.env.USERNAME_HV,
    password: process.env.PASSWORD_HV,
    host: process.env.FTPHOST,
    port: 21,
    localRoot: __dirname + "/",
    remoteRoot: "/home/hiversho/public_html/gitlab-pipeline-demo/",
    include: ['*']
}

ftpDeploy.deploy(config, function(err) {
    if (err) console.log(err)
    else console.log('finished');
});

如果有人想检查整个回购文件,checkout on github

在回购协议中,您的文件名为 .circleci/config.js,您正在尝试 运行 .circleci/deploy.js