IBM/openapi-validator

Cannot find module 'nimma/legacy' in OpenAPI

Closed this issue · 4 comments

I am getting following error while generating oas-sdk in OpenAPI on this command - lint-openapi api/blockchain-identity-service/openapi.yaml

lint-openapi api/blockchain-identity-service/openapi.yaml
internal/modules/cjs/loader.js:796
    throw err;
    ^

Error: Cannot find module 'nimma/legacy'
Require stack:
- /source/node_modules/@stoplight/spectral-core/dist/runner/runner.js
- /source/node_modules/@stoplight/spectral-core/dist/runner/index.js
- /source/node_modules/@stoplight/spectral-core/dist/spectral.js
- /source/node_modules/@stoplight/spectral-core/dist/index.js
- /source/node_modules/ibm-openapi-validator/src/cli-validator/run-validator.js
- /source/node_modules/ibm-openapi-validator/src/cli-validator/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/source/node_modules/@stoplight/spectral-core/dist/runner/runner.js:7:47)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Module.require (internal/modules/cjs/loader.js:848:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/source/node_modules/@stoplight/spectral-core/dist/runner/runner.js',
    '/source/node_modules/@stoplight/spectral-core/dist/runner/index.js',
    '/source/node_modules/@stoplight/spectral-core/dist/spectral.js',
    '/source/node_modules/@stoplight/spectral-core/dist/index.js',
    '/source/node_modules/ibm-openapi-validator/src/cli-validator/run-validator.js',
    '/source/node_modules/ibm-openapi-validator/src/cli-validator/index.js'
  ]
}
error: Recipe `lint-oas` failed on line 465 with exit code 1

I have observed we start getting this error when we upgrade ibm-openapi-validator package to 0.77.1 I have also tried with the latest package version 0.96.1 But with the latest version also I am getting the same error.
I have tried to add jest.config.js file as following this link - stoplightio/spectral#2002

module.exports = {
    moduleNameMapper: {
      '^nimma/legacy$': './node_modules/nimma/dist/legacy/cjs/index.js',
      '^nimma/(.*)': './node_modules/nimma/dist/cjs/$1',
      '^@stoplight/spectral-ruleset-bundler/(.*)$': './node_modules/@stoplight/spectral-ruleset-bundler/dist/$1',
      '^nimma/fallbacks$': './node_modules/nimma/dist/legacy/cjs/fallbacks/index.js'
    }
  }

But this is also not helping. I am getting same issue....

This will be resolved by #511

Resolved in 0.96.2

In 0.96.2 also, this problem is not resolved. Hence reopening the issue.

0.96.4 happened too.