-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
jet-brains-integration is assuming that process.cwd() is pointing to package root. If it is not, it crashes at this line:
| const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8")); |
Since the fs access is in the global scope, it crashes even if the code didn't directly generate the manifest - any indirect imports to jet-brains-integration trigger the error:
❯ yarn s2l:migrate
node:fs:448
return binding.readFileUtf8(path, stringToFlags(options.flag));
^
Error: ENOENT: no such file or directory, open 'package.json'
at Object.readFileSync (node:fs:448:20)
at file://.../node_modules/custom-element-jet-brains-integration/dist/index.js:256:34
at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:474:24)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:109:5) {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: 'package.json'
}Suggestions:
- Don't try to read package.json in the global scope - tests and other scripts may indirectly import the jet-brains-integration, with no intention of generating the manifest
- My workaround for now: async-import the bundle that includes the indirect import to jet-brains-integration only if needed
- Have jet-brains-integration look up the directory tree to find the nearest package.json OR, even better, let us explicitly provide you with a package.json contents (which would make mocking in tests easier too)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels