jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.49k stars 4.02k forks source link

ERROR! Cannot find module 'ajv/dist/compile/context' when executing jhipster jdl #14492

Closed sdebnath closed 3 years ago

sdebnath commented 3 years ago
Overview of the issue

Trying to import entities created using JDL created by the online JDL Studio but looks there's missing npm package when I just type jhipster jdl. The blank default project loads, manually tested and passes e2e test.

→ jhipster jdl            
INFO! Using JHipster version installed locally in current project's node_modules
ERROR! Cannot find module 'ajv/dist/compile/context'
Require stack:
- /Volumes/Workspace/Projects/project/node_modules/ajv-formats/dist/limit.js
- /Volumes/Workspace/Projects/project/node_modules/ajv-formats/dist/index.js
- /Volumes/Workspace/Projects/project/node_modules/conf/dist/source/index.js
- /Volumes/Workspace/Projects/project/node_modules/generator-jhipster/generators/statistics.js
- /Volumes/Workspace/Projects/project/node_modules/generator-jhipster/generators/app/prompts.js
- /Volumes/Workspace/Projects/project/node_modules/generator-jhipster/generators/app/index.js
- /Volumes/Workspace/Projects/project/node_modules/yeoman-environment/lib/store.js
- /Volumes/Workspace/Projects/project/node_modules/yeoman-environment/lib/environment.js
- /Volumes/Workspace/Projects/project/node_modules/generator-jhipster/cli/environment-builder.js
- /Volumes/Workspace/Projects/project/node_modules/generator-jhipster/cli/program.js
- /Volumes/Workspace/Projects/project/node_modules/generator-jhipster/cli/cli.js
- /usr/local/lib/node_modules/generator-jhipster/cli/jhipster.js
Error: Cannot find module 'ajv/dist/compile/context'
Require stack:
- /Volumes/Workspace/Projects/project/node_modules/ajv-formats/dist/limit.js
- /Volumes/Workspace/Projects/project/node_modules/ajv-formats/dist/index.js
- /Volumes/Workspace/Projects/project/node_modules/conf/dist/source/index.js
- /Volumes/Workspace/Projects/project/node_modules/generator-jhipster/generators/statistics.js
- /Volumes/Workspace/Projects/project/node_modules/generator-jhipster/generators/app/prompts.js
- /Volumes/Workspace/Projects/project/node_modules/generator-jhipster/generators/app/index.js
- /Volumes/Workspace/Projects/project/node_modules/yeoman-environment/lib/store.js
- /Volumes/Workspace/Projects/project/node_modules/yeoman-environment/lib/environment.js
- /Volumes/Workspace/Projects/project/node_modules/generator-jhipster/cli/environment-builder.js
- /Volumes/Workspace/Projects/project/node_modules/generator-jhipster/cli/program.js
- /Volumes/Workspace/Projects/project/node_modules/generator-jhipster/cli/cli.js
- /usr/local/lib/node_modules/generator-jhipster/cli/jhipster.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Volumes/Workspace/Projects/project/node_modules/ajv-formats/dist/limit.js:4:19)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Volumes/Workspace/Projects/project/node_modules/ajv-formats/dist/index.js:4:17)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Volumes/Workspace/Projects/project/node_modules/ajv-formats/dist/limit.js',
    '/Volumes/Workspace/Projects/project/node_modules/ajv-formats/dist/index.js',
    '/Volumes/Workspace/Projects/project/node_modules/conf/dist/source/index.js',
    '/Volumes/Workspace/Projects/project/node_modules/generator-jhipster/generators/statistics.js',
    '/Volumes/Workspace/Projects/project/node_modules/generator-jhipster/generators/app/prompts.js',
    '/Volumes/Workspace/Projects/project/node_modules/generator-jhipster/generators/app/index.js',
    '/Volumes/Workspace/Projects/project/node_modules/yeoman-environment/lib/store.js',
    '/Volumes/Workspace/Projects/project/node_modules/yeoman-environment/lib/environment.js',
    '/Volumes/Workspace/Projects/project/node_modules/generator-jhipster/cli/environment-builder.js',
    '/Volumes/Workspace/Projects/project/node_modules/generator-jhipster/cli/program.js',
    '/Volumes/Workspace/Projects/project/node_modules/generator-jhipster/cli/cli.js',
    '/usr/local/lib/node_modules/generator-jhipster/cli/jhipster.js'
  ],
  command: JHipsterCommand {
    _events: [Object: null prototype] {
      'option:version': [Function (anonymous)],
      afterHelp: [Function (anonymous)],
      'option:blueprints': [Function (anonymous)],
      'option:insight': [Function (anonymous)],
      'option:no-insight': [Function (anonymous)],
      'option:force': [Function (anonymous)],
      'option:no-force': [Function (anonymous)],
      'option:dry-run': [Function (anonymous)],
      'option:no-dry-run': [Function (anonymous)],
      'option:whitespace': [Function (anonymous)],
      'option:no-whitespace': [Function (anonymous)],
      'option:bail': [Function (anonymous)],
      'option:no-bail': [Function (anonymous)],
      'option:skip-regenerate': [Function (anonymous)],
      'option:no-skip-regenerate': [Function (anonymous)],
      'option:skip-yo-resolve': [Function (anonymous)],
      'option:no-skip-yo-resolve': [Function (anonymous)],
      'option:from-jdl': [Function (anonymous)],
      'option:no-from-jdl': [Function (anonymous)],
      'option:debug': [Function (anonymous)],
      'option:no-debug': [Function (anonymous)]
    },
    _eventsCount: 21,
    _maxListeners: undefined,
    commands: [
      [JHipsterCommand], [JHipsterCommand],
      [JHipsterCommand], [JHipsterCommand],
      [JHipsterCommand], [JHipsterCommand],
      [JHipsterCommand], [JHipsterCommand],
      [JHipsterCommand], [JHipsterCommand],
      [JHipsterCommand], [JHipsterCommand],
      [JHipsterCommand], [JHipsterCommand],
      [JHipsterCommand], [JHipsterCommand],
      [JHipsterCommand], [JHipsterCommand],
      [JHipsterCommand], [JHipsterCommand],
      [JHipsterCommand], [JHipsterCommand],
      [JHipsterCommand], [JHipsterCommand],
      [JHipsterCommand], [JHipsterCommand],
      [JHipsterCommand], [JHipsterCommand]
    ],
    options: [
      [Option], [Option], [Option],
      [Option], [Option], [Option],
      [Option], [Option], [Option],
      [Option], [Option], [Option],
      [Option], [Option], [Option],
      [Option], [Option], [Option],
      [Option], [Option]
    ],
    parent: null,
    _allowUnknownOption: false,
    _allowExcessArguments: true,
    _args: [],
    rawArgs: [
      '/usr/local/Cellar/node@14/14.16.0_1/bin/node',
      '/usr/local/bin/jhipster',
      'jdl'
    ],
    _scriptPath: '/usr/local/bin/jhipster',
    _name: 'jhipster',
    _optionValues: {
      force: false,
      dryRun: false,
      whitespace: false,
      bail: false,
      skipRegenerate: false,
      skipYoResolve: false,
      fromJdl: false
    },
    _storeOptionsAsProperties: false,
    _actionResults: [],
    _actionHandler: null,
    _executableHandler: false,
    _executableFile: null,
    _defaultCommandName: 'app',
    _exitCallback: null,
    _aliases: [],
    _combineFlagAndOptionalValue: true,
    _description: '',
    _argsDescription: undefined,
    _enablePositionalOptions: false,
    _passThroughOptions: false,
    _outputConfiguration: {
      writeOut: [Function: writeOut],
      writeErr: [Function: writeErr],
      getOutHelpWidth: [Function: getOutHelpWidth],
      getErrHelpWidth: [Function: getErrHelpWidth],
      outputError: [Function: outputError]
    },
    _hidden: false,
    _hasHelpOption: true,
    _helpFlags: '-h, --help',
    _helpDescription: 'display help for command',
    _helpShortFlag: '-h',
    _helpLongFlag: '--help',
    _addImplicitHelpCommand: undefined,
    _helpCommandName: 'help',
    _helpCommandnameAndArgs: 'help [command]',
    _helpCommandDescription: 'display help for command',
    _helpConfiguration: {},
    _version: '7.0.0',
    _versionOptionName: 'version',
    args: [ 'jdl' ],
    [Symbol(kCapture)]: false
  }
}
JHipster Info

→ jhipster info INFO! Using JHipster version installed locally in current project's node_modules Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
project@0.0.1-SNAPSHOT /Volumes/Workspace/Projects/project
└── generator-jhipster@7.0.0 
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "blueprints": [],
    "otherModules": [],
    "applicationType": "monolith",
    "baseName": "project",
    "jhipsterVersion": "7.0.0",
    "skipClient": false,
    "skipServer": false,
    "skipUserManagement": true,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "testFrameworks": ["cypress"],
    "pages": [],
    "creationTimestamp": 1616856001452,
    "serviceDiscoveryType": false,
    "reactive": false,
    "authenticationType": "oauth2",
    "packageName": "aero.project.apps",
    "serverPort": "8080",
    "cacheProvider": "redis",
    "enableHibernateCache": true,
    "databaseType": "sql",
    "devDatabaseType": "postgresql",
    "prodDatabaseType": "postgresql",
    "buildTool": "maven",
    "serverSideOptions": [],
    "websocket": false,
    "searchEngine": false,
    "messageBroker": false,
    "enableSwaggerCodegen": false,
    "clientFramework": "angularX",
    "withAdminUi": true,
    "clientTheme": "none",
    "enableTranslation": false,
    "nativeLanguage": "en",
    "packageFolder": "aero/project/apps",
    "clientPackageManager": "npm",
    "clientThemeVariant": "",
    "languages": ["en", "fr"]
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

openjdk version "11.0.10" 2021-01-19 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)

git version 2.24.3 (Apple Git-128)

node: v14.16.0

npm: 6.14.11

Docker version 20.10.5, build 55c4c88

docker-compose version 1.28.5, build c4eb3a1f

No change to package.json was detected. No package manager install will be executed. Congratulations, JHipster execution is complete! Sponsored with ❤️ by @oktadev.

pelverum commented 3 years ago

I am hitting this same problem after upgrading to generator-jhipster 7.0.0. Please advise as to host to resolve this issue or if a fix in in progress.

sendilkumarn commented 3 years ago

Yeah same here! Seeing the same issue with Kotlin generator

vishal423 commented 3 years ago

I guess it's due to mix of node_modules generated with npm 7 vs npm 6.

alexsintoni commented 3 years ago

I have the same issue. I have created two new JHipster v7.0.0 projects: one Gateway and and one Microservice. If I run jhipster jdl ~/Downloads/jhipster-jdl.jdl in the Microservice works fine, but when I run it in the Gateway I get the same error. Then out of curiosity, I have created a new Monolitich project with JHipster v7.0.0 and tried to run the same command but receive the same error.

mshima commented 3 years ago

I guess it's due to mix of node_modules generated with npm 7 vs npm 6.

Yes that's it.

Workarounds:

rburgst commented 3 years ago

@mshima tried that, didnt help

node --version
v14.16.0
➜  test-kotlin2 git:(master) ✗ npm --version  
7.7.6
➜  test-kotlin2 git:(master) ✗ 

running jhipster ci-cd gives the same problem

radzionkow commented 3 years ago

Same error here, but it happens when upgrading gateway app from 6.10.5 to 7.0.0 (jhipster upgrade). Specifically when generating 7.0.0 app version. Deleted node_modules and package-lock.json, but still no luck. Seems that @mshima workaround not always works.

node --version
v15.11.0
npm --version
7.7.6
mshima commented 3 years ago

This is an upstream bug cause by https://github.com/ajv-validator/ajv-formats/pull/15.

You can try the following workarounds:

hoomb commented 3 years ago

This has worked for me npm install --save-dev ajv@^7

pascalgrimaud commented 3 years ago

@radzionkow : sorry, I'm out of subject here but just becareful with the upgrade of the gateway as we needed to change the architecture. Old gateway used Zuul and Ribbon by default with Spring Mvc. New gateways use Spring Cloud Gateway and Spring Cloud Load Balancer with Spring Reactive

JeromeRider commented 3 years ago

This has worked for me npm install --save-dev ajv@^7

@hoomb This has worked for me too ty but I got conflicts when importing JDL after that npm install. My errors :

conflict src\main\webapp\i18n\fr\global.json ? Overwrite src\main\webapp\i18n\fr\global.json? overwrite force src\main\webapp\i18n\fr\global.json conflict src\main\webapp\i18n\en\global.json ? Overwrite src\main\webapp\i18n\en\global.json? do not overwrite skip src\main\webapp\i18n\en\global.json

Whatever conflict pops, I have to not overwrite to keep going.

I have those kinda conflicts for :

then got a ERROR Failed to compile with 70 errors

then a plethora amount of errors on such files, example ;

ERROR in src/main/webapp/app/entities/tool-type/tool-type-update.tsx:110:26 TS2339: Property 'category' does not exist on type 'IRootState'. 108 | 109 | const mapStateToProps = (storeState: IRootState) => ({

110 | categories: storeState.category.entities, | ^^^^^^^^ 111 | toolTypeEntity: storeState.toolType.entity, 112 | loading: storeState.toolType.loading, 113 | updating: storeState.toolType.updating,

Can't build my project so far because of the latest version it seems... Thank yall for the help !

madhavdutta commented 3 years ago

Thanks @hoomb it worked.

agamswarup1004 commented 4 months ago

This has worked for me npm install --save-dev ajv@^7 Thanks @hoomb

AbdelHamdyGhanem commented 3 months ago

This has worked for me npm install --save-dev ajv@^7

Thanks it worked!!

sumcodez commented 2 months ago

This has worked for me npm install --save-dev ajv@^7

Thanks man

Abhishek-ak3 commented 2 months ago

npm install --save-dev ajv@^7 this command really worked out for me!