0

我正在尝试创建与公共级别相同的隐藏点文件夹,以提供我每天生成的静态文件。

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

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

一切都在生产中运行,但在部署过程中出现错误:调用部署过程:失败

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

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 
4

1 回答 1

0

使用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);
})
于 2016-04-07T10:52:07.367 回答