I am working on a config npm module for my personal project. I have realized this repo with a Prettier, ESLint, tsconfig, …
My config tools repo: https://github.com/Seyrinian/seyrinian-tools
When I am trying to use it in one of my personal projects I am installing the package and I have the config in a index.js
file produced by the ts building of my tools repo.
Then I am calling my personal config in each equivalent config files (Prettier, ESLint, …).
Here is my test repo: https://github.com/Seyrinian/boilerplate-node
When I am trying the pnpm lint
command I have the following error:
Oops! Something went wrong! :(
ESLint: 9.4.0
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '~' imported from C:UsersUtilisateurWorkspaceboilerplate-nodenode_modules.pnpm@[email protected]node_modules@seyrinianseyrinian-toolsdistindex.js
at packageResolve (node:internal/modules/esm/resolve:854:9)
at moduleResolve (node:internal/modules/esm/resolve:927:18)
at defaultResolve (node:internal/modules/esm/resolve:1157:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
at link (node:internal/modules/esm/module_job:86:36)
ELIFECYCLE Command failed with exit code 2.
It seems it concerns my index.js
built by TypeScript on my tools project. But I don’t understand why itcan’t resolve this import.
It looks like that you are using ~ to link the files.
Replace the ~ with the relative path to your seyrinian-tools package in your project’s configuration files. Since it’s a local dependency, you can use a relative path like ../seyrinian-tools/dist/index.js (assuming your config files are in the same directory as your project’s root).