luizcorreia / spectral-language-server

Awesome Spectral JSON/YAML linter with OpenAPI/AsyncAPI support Spectral is a flexible object linter with out of the box support for OpenAPI v2 and v3, JSON Schema, and AsyncAPI.
MIT License
17 stars 5 forks source link

Dist files missing from installed package #3

Closed bsmith-optoro closed 2 years ago

bsmith-optoro commented 2 years ago

I'm getting the following error when trying to run this:

➜ spectral-language-server
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module '/home/bsmith/.asdf/installs/nodejs/16.14.0/.npm/lib/node_modules/spectral-language-server/dist/spectral-language-server/server.js'
Require stack:
- /home/bsmith/.asdf/installs/nodejs/16.14.0/.npm/lib/node_modules/spectral-language-server/bin/spectral-language-server
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/bsmith/.asdf/installs/nodejs/16.14.0/.npm/lib/node_modules/spectral-language-server/bin/spectral-language-server:3:1)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/bsmith/.asdf/installs/nodejs/16.14.0/.npm/lib/node_modules/spectral-language-server/bin/spectral-language-server'
  ]
}
➜ l /home/bsmith/.asdf/installs/nodejs/16.14.0/.npm/lib/node_modules/spectral-language-server
total 20K
drwxr-xr-x   2 4.0K Feb 14 21:36 bin/
drwxr-xr-x 153 4.0K Feb 14 21:37 node_modules/
-rw-r--r--   1 1.1K Feb 14 21:36 LICENSE
-rw-r--r--   1  896 Feb 14 21:36 package.json
-rw-r--r--   1  624 Feb 14 21:36 README.md

The only explanation I've found so far is the dist directory being in the .gitignore file. According to the npm docs:

If there is a .gitignore or .npmignore file, then ignored files in that and all child directories will be excluded from the package. If both files exist, then the .gitignore is ignored, and only the .npmignore is used.

Other sources say that files should override it, though.

ristillu commented 2 years ago

I'm getting the same error. My installation method was also just npm install -g spectral-language-server, not building manually.

williamgoulois commented 2 years ago

To fix this I just manually run scripts/build.sh and it works fine

bsmith-optoro commented 2 years ago

That does not exist when it's installed via npm.

williamgoulois commented 2 years ago

Sorry for misexplanation this is what I actually did :

I had to modify this line on the script : https://github.com/luizcorreia/spectral-language-server/blob/eaab841be81d52ef8a64423a37dfd9c4628e33d2/script/vscode-spectral-build.sh#L22 to yarn install --ignore-engines because i didn't want to install node 12.13 just to compile it (i used node 14.15.5 to do it)

luizcorreia commented 2 years ago

Hi @williamgoulois good to know that works for you. Can you make a PR fixing it? I tried some things, but the script just don't fire on installing by npm.

williamgoulois commented 2 years ago

Hi @luizcorreia, I realized i didn't even need this package. I'm using nvim-lsp-installer and they already provide the installation steps that this project recreates.

This is how they handle the installation : https://github.com/williamboman/nvim-lsp-installer/blob/918ef1d4484d703e42424292399d19e36aab436f/lua/nvim-lsp-installer/servers/spectral/init.lua#L14-L31

I created a PR to fix the issues #4