forest-express
forest-express copied to clipboard
Yarn v2 breaks Schema creation
Expected behavior
Schema is expected to be created successfully.
Actual behavior
Errors out with EROFS: read-only filesystem, open '/.forestadmin-schema.json'
Failure Logs
Context
- Package Version: 6.3.0
- Express Version: 4.17.1
- Yarn v2
Yarn v2 has introduced a new way of storing dependencies, i.e. not in node_modules, but rather in a cache with dependencies zipped up. This breaks forest-express's getAbsolutePath utility.: https://github.com/ForestAdmin/forest-express/blob/f632e0369d03057372bec04fae13a3da83e319c8/src/utils/project-directory.js#L10
Since the dir no longer has 'node_modules', it is taking the fork return process.cwd()
, which is returning ''
(not sure why, possibly because it's running from a zipped file?), which causes this: https://github.com/ForestAdmin/forest-express/blob/f632e0369d03057372bec04fae13a3da83e319c8/src/index.js#L35
to return an absolute path that is '/.forestadmin-schema.json'.
The temporary solution is to yarn unplug forest-express
, but if Yarn v2 is going to become more widely used, this should probably be fixed.
I agree, we are migrating to yarn 2 and this was a problem for us too! :)
Unplugging it is not working either. If you use the default directory of unplugged modules, it puts the .forestadmin-schema.json file under .yarn/unplugged/forest-express...
But actually, the path, not unplugged, is: path/to/dir/.yarn/cache/forest-express-npm-version.zip/node_modules/forest-express/dist/utils
, so it doesn't do process.cwd()
I think an option to set the absolute path would be the best solution (at least for us)
It's now (for a while) supported. Thank you all for your contributions.
#697