如何使用隐藏点文件夹 (/.files) 进行部署或在生产环境中创建点文件夹
How to deploy with hidden dot folder (/.files) or create dot folder on production
我正在尝试创建与 public 相同级别的隐藏点文件夹,以提供我每天生成的静态文件。
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
使用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);
})
我正在尝试创建与 public 相同级别的隐藏点文件夹,以提供我每天生成的静态文件。
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
使用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);
})