Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

running spectral CLI yields ERR_PACKAGE_PATH_NOT_EXPORTED error in @stoplight/spectral-ruleset-bundler/package.json #2080

Closed
DavidBiesack opened this issue Mar 7, 2022 · 3 comments

Comments

@DavidBiesack
Copy link

DavidBiesack commented Mar 7, 2022

When I try to install latest

$ npm i -g @stoplight/spectral-cli
$ type spectral
spectral is hashed (~/.nvm/versions/node/v12.18.3/bin/spectral)

running spectral yields an error:

$ spectral lint -r .spectral.yaml openapi.yaml
internal/modules/cjs/loader.js:490
  throw new ERR_PACKAGE_PATH_NOT_EXPORTED(basePath, mappingKey);
  ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './presets/node' is not defined by "exports" in ~/.nvm/versions/node/v12.18.3/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-ruleset-bundler/package.json
    at applyExports (internal/modules/cjs/loader.js:490:9)
    at resolveExports (internal/modules/cjs/loader.js:506:23)
    at Function.Module._findPath (internal/modules/cjs/loader.js:634:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:952:27)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (~/.nvm/versions/node/v12.18.3/lib/node_modules/@stoplight/spectral-cli/dist/services/linter/utils/getRuleset.js:13:16)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

and I get the same problem if I uninstall then install earlier versions such as
@stoplight/[email protected] and @stoplight/[email protected]

Only 6.0.0 works for me

$ spectral --version
6.0.0
@P0lip
Copy link
Contributor

P0lip commented Mar 7, 2022

spectral is hashed (~/.nvm/versions/node/v12.18.3/bin/spectral)

Judging by the version of Node specified in the directory path, you might be running an unsupported version of Node.
This is the minimum required versions we support
https://github.com/stoplightio/spectral/blob/develop/packages/cli/package.json#L11

LMK if that's indeed the case

@DavidBiesack
Copy link
Author

Thanks, that was the problem. I upgraded to 12.21.0 and the CLI works.

(Is this perhaps a bug in NPM that it does not enforce the node version required by a package ?)

@P0lip
Copy link
Contributor

P0lip commented Mar 7, 2022

(Is this perhaps a bug in NPM that it does not enforce the node version required by a package ?)

hmmm, nothing that I'm aware of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants