marko-js / language-server

Marko autocomplete, intellisense and editor support.
MIT License
38 stars 8 forks source link

Crash on startup of `@marko/type-check` #203

Closed vwong closed 12 months ago

vwong commented 1 year ago

@marko/language-tools@2.1.1

└─┬ @marko/type-check@0.0.15 └── @marko/language-tools@2.1.1

Details

A recent upgrade to @marko/language-tools broke @marko/type-check.

I was using @marko/type-check@0.0.15 and only upgraded transitive dependencies in my package-lock.json and the below error started to occur. Upgrading all of my @marko/* packages, including to @marko/type-check@0.0.16 did not help.

Expected Behavior

mtc to type-check my Marko files.

Actual Behavior

mtc crashed with the following error message.

> mtc

/node_modules/@marko/language-tools/dist/index.js:3072
      throw new Error(
      ^

Error: @marko/compiler must be installed or compiler registered.
    at getMeta (/node_modules/@marko/language-tools/dist/index.js:3072:13)
    at getMeta (/node_modules/@marko/language-tools/dist/index.js:3102:16)
    at getConfig (/node_modules/@marko/language-tools/dist/index.js:2950:10)
    at getTypeLibs (/node_modules/@marko/language-tools/dist/index.js:2957:18)
    at Object.create (/node_modules/@marko/language-tools/dist/index.js:3168:26)
    at Object.create (/node_modules/@marko/language-tools/dist/index.js:3322:46)
    at createCompilerHost (/node_modules/@marko/type-check/dist/cli.js:337:55)
    at run (/node_modules/@marko/type-check/dist/cli.js:81:53)
    at Object.<anonymous> (/node_modules/@marko/type-check/dist/cli.js:591:3)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)

Node.js v18.13.0

Your Environment

Node.js v18.13.0 MacOS 13.4.1

DylanPiercey commented 1 year ago

@vwong can you npm ls @marko/compiler?

vwong commented 1 year ago

With older versions of @marko/type-check and marko

├─┬ @marko/run@0.2.0
│ └─┬ @marko/vite@2.4.8
│   └── @marko/compiler@5.31.2 deduped
├─┬ @marko/type-check@0.0.16
│ └─┬ @marko/language-tools@2.1.2
│   └── @marko/compiler@5.31.2 deduped
├─┬ marko@5.29.1
│ ├── @marko/compiler@5.31.2
│ └─┬ @marko/translator-default@5.29.2
│   └── @marko/compiler@5.31.2 deduped
└─┬ prettier-plugin-marko@2.0.1
  └── @marko/compiler@5.31.2 deduped

With latest version of @marko/type-check and marko, (and everything else at NPM latest)

├─┬ @marko/run@0.2.0
│ └─┬ @marko/vite@2.4.8
│   └── @marko/compiler@5.31.2 deduped
├─┬ @marko/type-check@0.0.16
│ └─┬ @marko/language-tools@2.1.2
│   └── @marko/compiler@5.31.2 deduped
├─┬ marko@5.29.2
│ ├── @marko/compiler@5.31.2
│ └─┬ @marko/translator-default@5.29.2
│   └── @marko/compiler@5.31.2 deduped
└─┬ prettier-plugin-marko@2.0.1
  └── @marko/compiler@5.31.2 deduped

Both give the same error.

DylanPiercey commented 1 year ago

@vwong does adding @marko/compiler as a devDependency resolve the issue? It should (part of the issue here is that most of these packages have the compiler as a "peerDendency"). The type-check package incorrectly had it as a direct dep causing invalid duplication.

vwong commented 12 months ago

Nope, that didn't work. Same deal as before.

DylanPiercey commented 12 months ago

@vwong could you try @marko/type-check@0.0.17? I suspect it will give a different error.

vwong commented 12 months ago

Different error, alright

> mtc

node:internal/modules/cjs/loader:1042
  throw err;
  ^

Error: Cannot find module 'marko/package.json'
Require stack:
- 
    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at Function.resolve (node:internal/modules/cjs/helpers:109:19)
    at loadMeta (/node_modules/@marko/language-tools/dist/index.js:3097:47)
    at getMeta (/node_modules/@marko/language-tools/dist/index.js:3086:10)
    at getConfig (/node_modules/@marko/language-tools/dist/index.js:2950:10)
    at getTypeLibs (/node_modules/@marko/language-tools/dist/index.js:2957:18)
    at Object.create (/node_modules/@marko/language-tools/dist/index.js:3180:26)
    at Object.create (/node_modules/@marko/language-tools/dist/index.js:3334:46)
    at createCompilerHost (/node_modules/@marko/type-check/dist/cli.js:337:55)
    at run (/node_modules/@marko/type-check/dist/cli.js:81:53) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '' ]
}

Node.js v18.13.0

This is with all the latest packages from npm right now. Ignoring transitive dependencies, this is what I tried installing in package.json

"@marko/run": "^0.2.0",
"@marko/testing-library": "^6.1.4",
"@marko/type-check": "^0.0.17",
"marko": "^5.29.2",
"prettier-plugin-marko": "^2.0.1",