如何使用隐藏点文件夹(/.files)进行部署或在生产中创建点文件夹

时间:2016-04-03 21:31:20

标签: node.js meteor meteor-up

我试图在与公众相同的级别上创建隐藏的点文件夹,以便为我每天生成的静态文件提供服务。

var fs = Npm.require('fs');

Meteor.startup(function() {
  var dir = './../../../../../.files';
  if (!fs.existsSync(dir)){
      fs.mkdirSync(dir);
  }
  routePath = fs.realpathSync(dir);
})

一切都适用于生产,但我在部署期间遇到错误:调用部署过程:FAILED

日志显示我无法创建此文件夹:

Error: EACCES, permission denied './../../../../../.files'
    at Object.fs.mkdirSync (fs.js:654:18)
    at Router.map.route.where (server/server_router.js:7:10)
    at /opt/appname/app/programs/server/boot.js:249:5
error: Forever detected script exited with code: 7
error: Script restart attempt #14 

1 个答案:

答案 0 :(得分:0)

Solved it using https://www.npmjs.com/package/mkdirp

var mkdirp = Meteor.npmRequire('mkdirp');

Meteor.startup(function() {
  var dir = './../../../../../.folder';

  mkdirp(dir, function (err) {
    if (err) console.error(err)
    else console.log('.folder created')
  });

  routePath = fs.realpathSync(dir);
})