pkg
pkg copied to clipboard
"Cannot mkdir in a snapshot. Try mount points instead."
How do I try a mount point?
Same problem here. What are mountpoints?
This will happen if you have something like this:
const logDir = 'app/logs';
if ( !fs.existsSync( logDir ) ) {
// Create the directory if it does not exist
fs.mkdirSync( logDir );
}
You could create app/logs
so it always exists and add it to pacakge.json
:
...
"pkg": {
"assets": [
"app/logs/**"
]
},
...
What is the best way to support creating directories dynamically? Is it possible to mkdir in one of the assets/mountpoint folders?
Relevant question. Completely unclear how to mkdir while executing packed.
@maxpavlov check: https://github.com/vercel/pkg/blob/main/prelude/bootstrap.js#L1505
Same problem, any solution?
Same thing on my side - had great hopes for this, highly disappointed at the moment by this error
I solved this problem by using process.cwd() to get your pkg execute path, which you can use this to create new dir. Because pkg use snapshot filesystem, orign __dirname, __filename were hijacked.. see README Snapshot filesystem part..
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label
any fix?
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label
This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.
Any suggestion to fix this issue???
In case anyone comes across this. I was having an issue using "winston" to log my files.
I was using filename: path.join(__dirname, "./logs/error.log")
What solved it for me, was to change it to filename: path.join(process.cwd(), "./logs/error.log")
If you console log both __dirname and process.cwd() in a working executable package (make a simple project and test it), you will see why.
Good luck!