isaacs / tshy

Other
894 stars 18 forks source link

Tshy fails: ENOENT: no such file or directory, open '.tshy-build/esm/package.json' #77

Closed sebastianwessel closed 4 months ago

sebastianwessel commented 4 months ago

Hi,

thanks for your cool tool. I use it for a while now, for a couple of projects.

I have set up a new repo, but it fails, when I run tshy. It looks like some internal issue.

package.json

I

{
...
    "type": "module",
    "files": ["dist"],
    "tshy": {
        "exclude": ["src/**/*.test.ts"],
        "dialects": ["esm", "commonjs"]
    },
    "scripts": {
        "build": "tshy",
        "test": "vitest",
        "lint": "bunx @biomejs/biome check",
        "lint:fix": "bunx @biomejs/biome check --write"
    },
    "devDependencies": {
        "tshy": "^1.16.2",
        ....
    },
    "dependencies": {
        ...
    }
}

Here is the output:

npx tshy
node:fs:2346
    return binding.writeFileUtf8(
                   ^

Error: ENOENT: no such file or directory, open '.tshy-build/esm/package.json'
    at writeFileSync (node:fs:2346:20)
    at writeDialectPJ (file:///Users/sebastianwessel/projekte/wasmer/node_modules/tshy/dist/esm/set-folder-dialect.js:15:5)
    at default (file:///Users/sebastianwessel/projekte/wasmer/node_modules/tshy/dist/esm/set-folder-dialect.js:20:5)
    at buildESM (file:///Users/sebastianwessel/projekte/wasmer/node_modules/tshy/dist/esm/build-esm.js:26:9)
    at default (file:///Users/sebastianwessel/projekte/wasmer/node_modules/tshy/dist/esm/build.js:27:9)
    at async main (file:///Users/sebastianwessel/projekte/wasmer/node_modules/tshy/dist/esm/index.js:26:5)
    at async file:///Users/sebastianwessel/projekte/wasmer/node_modules/tshy/dist/esm/index.js:29:1 {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '.tshy-build/esm/package.json'
}

Node.js v20.15.0

It is also creating a package.json file inside the /src folder.

A folder .tshy is created , which contains build.json, commonjs.json and esm.json.

My folder structure follows the "regular" schema, with src/index.ts

Node : 20.15 OS: MacOS 14.5 M2

DaniGuardiola commented 4 months ago

I am also running into this. Node.js v22.3.0, in Windows 11 (WSL Ubuntu). I'm running the script with bun, though I don't think that matters.

DaniGuardiola commented 4 months ago

Ah, this is the same issue that I already ran into and fixed lol, see #27. Remove "noEmit": true from your tsconfig.json file.

sebastianwessel commented 4 months ago

Ah, thx. Yes it's "noEmit": true.

I'm also using bun and copied the tsconfig from bun.sh.

Disabling noEmit and allowImportingTsExtensions fixed the issue 👍

Should I close the issue then?

DaniGuardiola commented 4 months ago

Yep, it's a duplicate and it's solved.