isaacs / rimraf

A `rm -rf` util for nodejs
ISC License
5.66k stars 252 forks source link

Module `minimatch/dist/mjs/index.js` not found #301

Closed siguici closed 6 months ago

siguici commented 7 months ago

node:internal/modules/esm/resolve:265 throw new ERR_MODULE_NOT_FOUND( ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/path-to-my-project/node_modules/rimraf/node_modules/glob/node_modules/minimatch/dist/mjs/index.js' imported from /path-to-my-project/node_modules/rimraf/node_modules/glob/dist/esm/index.js at finalizeResolution (node:internal/modules/esm/resolve:265:11) at moduleResolve (node:internal/modules/esm/resolve:933:10) at defaultResolve (node:internal/modules/esm/resolve:1157:11) at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12) at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25) at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:234:38) at ModuleWrap. (node:internal/modules/esm/module_job:87:39) at link (node:internal/modules/esm/module_job:86:36) { code: 'ERR_MODULE_NOT_FOUND', url: 'file:///labs/path-to-my-project/node_modules/rimraf/node_modules/glob/node_modules/minimatch/dist/mjs/index.js' }

jonkoops commented 6 months ago

If you want to have your issue resolved I recommend that you provide reproducible steps for the problem, otherwise it will just be closed.

siguici commented 6 months ago

Sorry for the late reply and for the lack of details. You can reproduce the bug as follows:

1- Clone the repository at https://github.com/siguici/reflex.js 2- Install dependencies with bun install 3- Then execute the bun run build command

The error is at this level. This command is supposed to clean up previous builds using rimraf before building again.

jonkoops commented 6 months ago

I am not able to reproduce this issue @siguici. I've got Bun 1.1.4 installed (which is the latest), and running the aforementioned steps only yields a bunch of TypeScript errors from the build:

Logs ``` $ bun run build.node && bun run build.deno $ cp README.md LICENSE.md out/node && rimraf out/node/ts out/node/ts && tsc --build src/reflex.test.ts:2:8 - error TS1192: Module '"/home/jon/Projects/trash/reflex.js/src/reflex"' has no default export. 2 import reflex, { ~~~~~~ src/reflex.test.ts:35:9 - error TS6133: 'class_method' is declared but its value is never read. 35 const class_method = Foo.bar; ~~~~~~~~~~~~ src/reflex.test.ts:35:28 - error TS2339: Property 'bar' does not exist on type 'typeof Foo'. 35 const class_method = Foo.bar; ~~~ src/reflex.test.ts:40:40 - error TS2339: Property 'getParameter' does not exist on type 'ReflectionObject | ReflectionFunction'. Property 'getParameter' does not exist on type 'ReflectionObject'. 40 const arrow_param = arrow_reflection.getParameter("name"); ~~~~~~~~~~~~ src/reflex.test.ts:41:40 - error TS2339: Property 'getParameter' does not exist on type 'ReflectionObject | ReflectionFunction'. Property 'getParameter' does not exist on type 'ReflectionObject'. 41 const named_param = named_reflection.getParameter("name"); ~~~~~~~~~~~~ node_modules/bun-types/globals.d.ts:2066:6 - error TS2403: Subsequent variable declarations must have the same type. Variable 'Response' must be of type 'typeof Response', but here has type 'typeof Response'. 2066 var Response: typeof globalThis extends { ~~~~~~~~ node_modules/@types/node/globals.d.ts:385:9 385 var Response: typeof globalThis extends { ~~~~~~~~ 'Response' was also declared here. node_modules/bun-types/globals.d.ts:2073:6 - error TS2403: Subsequent variable declarations must have the same type. Variable 'Request' must be of type 'typeof Request', but here has type '{ new (requestInfo: string, requestInit?: RequestInit | undefined): Request; new (requestInfo: RequestInit & { url: string; }): Request; new (requestInfo: Request, requestInit?: RequestInit | undefined): Request; prototype: Request; }'. 2073 var Request: typeof globalThis extends { ~~~~~~~ node_modules/@types/node/globals.d.ts:376:9 376 var Request: typeof globalThis extends { ~~~~~~~ 'Request' was also declared here. node_modules/bun-types/overrides.d.ts:3:20 - error TS2305: Module '"bun"' has no exported member 'PathLike'. 3 import type { Env, PathLike, BunFile } from "bun"; ~~~~~~~~ Found 8 errors. error: script "build.node" exited with code 1 error: script "build" exited with code 1 ```
isaacs commented 6 months ago

The error message indicates that the version of minimatch/glob being provided to rimraf are not the versions that it declares as dependencies.

I can't help you. If your package manager gives my code the wrong deps, instead of the versions that rimraf states it's compatible with, then it won't be compatible and it won't work.

Looks like a bun issue, if that's the package manager you used to install this broken setup. But it works for everyone else. Not a rimraf bug.

siguici commented 6 months ago

The error message indicates that the version of minimatch/glob being provided to rimraf are not the versions that it declares as dependencies.

I can't help you. If your package manager gives my code the wrong deps, instead of the versions that rimraf states it's compatible with, then it won't be compatible and it won't work.

Looks like a bun issue, if that's the package manager you used to install this broken setup. But it works for everyone else. Not a rimraf bug.

Indeed, the issue seems to be related to Bun. I've encountered similar errors with other packages in different projects. I've used rimraf in other projects without encountering any issues.

Thank you for your understanding and sorry for the inconvenience.

jonkoops commented 6 months ago

@siguici perhaps try deleting all the node_modules and bun.lockb and re-install the packages, that has fixed stuff for me before.

isaacs commented 6 months ago

Everyone: please stop reporting and discussing package manager errors in the issues of the libraries affected by them. We can't fix them for you. Take it to bun, or yarn, or npm, or whatever you're using. "I got the wrong version of a dep" is almost never the fault of the dep itself, but whatever is loading it and choosing the wrong version.

I get a ton of isues like this, and I will be immediately closing and locking all of them moving forward.