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

Error due to invalid import statement #59

Open
naris opened this issue Oct 6, 2022 · 4 comments
Open

Error due to invalid import statement #59

naris opened this issue Oct 6, 2022 · 4 comments

Comments

@naris
Copy link

naris commented Oct 6, 2022

There are 4 places where an import statement tries to import a directory in the latest version (7.9.3). This is not valid and causes errors https://stackoverflow.com/questions/64453859/directory-import-is-not-supported-resolving-es-modules-with-node-js.

This was posted before in issue #58 but was immediately closed without any investigation whatsoever.

The suggested fix from stackoverflow is to append /index.js, which does indeed work. I have created pull request #60 with the fix.

@yelhouti
Copy link
Contributor

yelhouti commented Oct 7, 2022

@naris this actually how the next release of generator-jhipster will work, I tracked the change earlier to: jhipster/generator-jhipster#19823
And asked mshima about it, but I understand why they did it (they are switching to esm) .
The generator also works for composite keys with not enough support in the main generator, so the only way for all this to work is to use by branch:
https://github.com/yelhouti/generator-jhipster/tree/composite-key
This hopefully will work better on the next release.

To use this branch, checkout my branch locally, and run inside of the project

npm install
npm link

This will configure npm to use my branch when asked instead of the default release.

The in your project (The one you are trying to generate) run:

npm link generator-jhipster

This will create a sim link to my branch in in the node_modules of your project (this needs to be be done after each npm install that breaks the link).

Hope this helps

@naris
Copy link
Author

naris commented Oct 10, 2022

Unfortunately, I am unable to run npm install after checking out the composite-key branch :(

> [email protected] copy-files
> cpy 'generators/**' '!**/*.(js|ts|cjs|mjs|snap)' '!**/__*/*' dist/generators && cpy 'package.json' dist

'ts' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code 255
npm ERR! path C:\src\generator-jhipster-yelhouti
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c npm run build

The log has

1150 verbose stack Error: command failed
1150 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27)
1150 verbose stack     at ChildProcess.emit (node:events:526:28)
1150 verbose stack     at maybeClose (node:internal/child_process:1092:16)
1150 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
1151 verbose pkgid [email protected]
1152 verbose cwd C:\src\generator-jhipster-yelhouti
1153 verbose Windows_NT 10.0.19044
1154 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
1155 verbose node v16.14.2
1156 verbose npm  v8.5.0
1157 error code 255
1158 error path C:\src\generator-jhipster-yelhouti
1159 error command failed
1160 error command C:\WINDOWS\system32\cmd.exe /d /s /c npm run build```

@naris
Copy link
Author

naris commented Oct 10, 2022

I have created an issue for the npm install problem in jhipster's project

@yelhouti
Copy link
Contributor

@naris new release 7.9.4 with some small fixes

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