lukeed / tsm

TypeScript Module Loader
MIT License
1.19k stars 19 forks source link

Compatibility with Yarn 2 (Berry)? #26

Closed azat-io closed 2 years ago

azat-io commented 2 years ago

I tried to use the tsm package with command yarn tsm uvu tests and got the following error:

Error: ENOTDIR: not a directory, stat '/Users/user/Developer/project-name/.yarn/cache/tsm-npm-2.2.1-7322a65949-ec9c0c59f0.zip/node_modules/tsm/loader.mjs'
    at statSync (fs.js:1131:3)
    at tryStatSync (internal/modules/esm/resolve.js:109:13)
    at finalizeResolution (internal/modules/esm/resolve.js:301:17)
    at moduleResolve (internal/modules/esm/resolve.js:731:10)
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:842:11)
    at Loader.resolve (internal/modules/esm/loader.js:89:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
    at Loader.import (internal/modules/esm/loader.js:177:28)
    at internal/process/esm_loader.js:57:31
    at initializeLoader (internal/process/esm_loader.js:62:5) {
  errno: -20,
  syscall: 'stat',
  code: 'ENOTDIR',
  path: '/Users/user/Developer/project-name/.yarn/cache/tsm-npm-2.2.1-7322a65949-ec9c0c59f0.zip/node_modules/tsm/loader.mjs'
}
lukeed commented 2 years ago

You have to provide a file to tsm, so it'd need to be something like tsm node_modules/uvu/bin.js ...

azat-io commented 2 years ago

If i run just yarn tsm I'll get the same error

lukeed commented 2 years ago

Because you need a file path...? Try yarn tsm file.ts

azat-io commented 2 years ago

The same error

azat-io commented 2 years ago

I have created repository where you can check the problem: https://github.com/azat-io/yarn-berry-tsm-example

TrySound commented 2 years ago

cc @arcanis

azat-io commented 2 years ago

Any ideas how to run uvu tests with Yarn Berry and TypeScript?

lukeed commented 2 years ago

It should be like any other environment. If it's not, then it's entirely Yarn@2 related

vire commented 2 years ago

@lukeed I have a very similar problem like @azat-io described.

running yarn tsm ./src/myfile.ts results into

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/User/github/myproject/.yarn/cache/tsm-npm-2.2.1-7322a65949-7fcbe7d4c9.zip/node_modules/tsm/loader.mjs' imported from /User/github/myproject/app/
Did you mean to import /User/github/myproject/.yarn/cache/tsm-npm-2.2.1-7322a65949-7fcbe7d4c9.zip/node_modules/tsm/loader.mjs?