node.jstypescriptstoplight

stoplight Cannot find module '@stoplight/spectral-ruleset-bundler/with-loader' or its corresponding type declarations.ts


Trying to implement example-2.mjs from spotlight Js code sample -> link

I am using express,node and typescript to implement js api linting. I copied sample example and tried running on vscode in express. Getting following error.

Tried following this -> https://github.com/stoplightio/spectral/issues/2092 where one user had similar issue but he was using commonjs where as I am using ES module.

Added type: module in package.json tried changing extension. that didn' help.

Tried few options by adding export in tsconfig (screenshot below), also in package.json. didn't work out

I think something is off here -> package.json of spectral-ruleset-bundler (screenshot at very bottom)

enter image description here

Package.json -> enter image description here

tsconfig.json -> enter image description here

enter image description here


Solution

  • Changed noduleResolution from node to node16 and it worked without any modification to spectral-ruleset-bundler package.json

    enter image description here