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

Illegal char <:> at index 4: node:internal/modules/cjs/loader:936 #73

Open
leaumar opened this issue Sep 7, 2022 · 11 comments
Open

Illegal char <:> at index 4: node:internal/modules/cjs/loader:936 #73

leaumar opened this issue Sep 7, 2022 · 11 comments

Comments

@leaumar
Copy link

leaumar commented Sep 7, 2022

Not sure if this is an issue for this repo or for jhipster/prettier-java. I just tried setting up this plugin in our project, and all my attempts to run it yield this error message:

Illegal char <:> at index 4: node:internal/modules/cjs/loader:936

I took the config from your readme, removed what I didn't need, and tried updating the versions too. I also noticed using the implicit default inputGlobs yields paths with mixed forward and backward slashes (windows) in print-args, specifying the inputGlobs as per the readme makes them consistent. I thought the backslashes might be causing the syntax error, but apparently that's not it.

image

[INFO] --- prettier-maven-plugin:0.18:print-args (default-cli) @ dfrecall ---
nodeExecutable=C:\Users\leaumar.m2\repository\com\hubspot\maven\plugins\prettier-maven-plugin\0.18\node-v16.13.2-win-x64\node.exe
npmCommand=C:\Users\leaumar.m2\repository\com\hubspot\maven\plugins\prettier-maven-plugin\0.18\node-v16.13.2-win-x64\node.exe C:\Users\leaumar.m2\repository\com\hubspot\maven\plugins\prettier-maven-plugin\0.18\node-v16.13.2-win-x64\node_modules\npm\bin\npm-cli.js
prettierBin=C:\Users\leaumar.m2\repository\com\hubspot\maven\plugins\prettier-maven-plugin\0.18\prettier-java-1.6.2\node_modules\prettier\bin-prettier.js
prettierJavaPlugin=C:\Users\leaumar.m2\repository\com\hubspot\maven\plugins\prettier-maven-plugin\0.18\prettier-java-1.6.2\node_modules\prettier-plugin-java
printWidth=120
inputGlob=src\main\java//*.java
inputGlob=src\test\java/
/*.java

Any advice or help, please?

@jhaber
Copy link
Member

jhaber commented Sep 7, 2022

Do you get the same error when you run from the commandline? If so can you run with -e to get a full stack trace for the error? Also if you run with -X this message should get printed:

getLog().debug("Running prettier with args: " + String.join(" ", command));

@leaumar
Copy link
Author

leaumar commented Sep 7, 2022

./mvnw -X prettier:check

[DEBUG] Determined os: WINDOWS_X64
[DEBUG] Reusing cached node at: C:\Users\leaumar\.m2\repository\com\hubspot\maven\plugins\prettier-maven-plugin\0.18\node-v16.13.2-win-x64
[DEBUG] Reusing cached prettier-java at: C:\Users\leaumar\.m2\repository\com\hubspot\maven\plugins\prettier-maven-plugin\0.18\prettier-java-1.6.2
[DEBUG] Running prettier with args: C:\Users\leaumar\.m2\repository\com\hubspot\maven\plugins\prettier-maven-plugin\0.18\node-v16.13.2-win-x64\node.exe C:/Users/leaumar/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.2
/node_modules/prettier/bin-prettier.js --plugin=C:/Users/leaumar/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.2/node_modules/prettier-plugin-java --color --print-width 120 --check src\main\java/**/*.java src\test\ja
va/**/*.java

./mvnw -e prettier:check

[ERROR] Failed to execute goal com.hubspot.maven.plugins:prettier-maven-plugin:0.18:check (default-cli) on project dfrecall: Execution default-cli of goal com.hubspot.maven.plugins:prettier-maven-plugin:0.18:check failed: Illegal char <:> at index 4: node:
internal/modules/cjs/loader:936 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.hubspot.maven.plugins:prettier-maven-plugin:0.18:check (default-cli) on project dfrecall: Execution default-cli of goal com.hubspot.maven.plugins:prettier-maven-plugin:0.18:
check failed: Illegal char <:> at index 4: node:internal/modules/cjs/loader:936
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:47)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:156)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:72)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal com.hubspot.maven.plugins:prettier-maven-plugin:0.18:check failed: Illegal char <:> at index 4: node:internal/modules/cjs/loader:936
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:47)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:156)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:72)
Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 4: node:internal/modules/cjs/loader:936
    at sun.nio.fs.WindowsPathParser.normalize (WindowsPathParser.java:182)
    at sun.nio.fs.WindowsPathParser.parse (WindowsPathParser.java:153)
    at sun.nio.fs.WindowsPathParser.parse (WindowsPathParser.java:77)
    at sun.nio.fs.WindowsPath.parse (WindowsPath.java:92)
    at sun.nio.fs.WindowsFileSystem.getPath (WindowsFileSystem.java:232)
    at java.nio.file.Path.resolve (Path.java:515)
    at com.hubspot.maven.plugins.prettier.CheckMojo.resolveFile (CheckMojo.java:104)
    at com.hubspot.maven.plugins.prettier.CheckMojo.handlePrettierLogLine (CheckMojo.java:43)
    at com.hubspot.maven.plugins.prettier.AbstractPrettierMojo.execute (AbstractPrettierMojo.java:78)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:47)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:156)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:72)

@leaumar
Copy link
Author

leaumar commented Sep 7, 2022

FYI just adding our own node and yarn3 and running prettier ourselves with prettier-plugin-java works fine

@jhaber
Copy link
Member

jhaber commented Sep 8, 2022

If you run this command directly what does the output look like?C:\Users\leaumar\.m2\repository\com\hubspot\maven\plugins\prettier-maven-plugin\0.18\node-v16.13.2-win-x64\node.exe C:/Users/leaumar/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.2/node_modules/prettier/bin-prettier.js --plugin=C:/Users/leaumar/.m2/repository/com/hubspot/maven/plugins/prettier-maven-plugin/0.18/prettier-java-1.6.2/node_modules/prettier-plugin-java --color --print-width 120 --check src\main\java/**/*.java src\test\java/**/*.java

And then what if you convert all the forward slashes to backslashes? For example:
C:\Users\leaumar\.m2\repository\com\hubspot\maven\plugins\prettier-maven-plugin\0.18\node-v16.13.2-win-x64\node.exe C:\Users\leaumar\.m2\repository\com\hubspot\maven\plugins\prettier-maven-plugin\0.18\prettier-java-1.6.2\node_modules\prettier\bin-prettier.js --plugin=C:\Users\leaumar\.m2\repository\com\hubspot\maven\plugins\prettier-maven-plugin\0.18\prettier-java-1.6.2\node_modules\prettier-plugin-java --color --print-width 120 --check src\main\java\**\*.java src\test\java\**\*.java

@jhaber
Copy link
Member

jhaber commented Sep 8, 2022

If we can get the args right so that one of these direct calls works (without Maven), it should be pretty straight-forward to update the plugin code to generate that same invocation

@leaumar
Copy link
Author

leaumar commented Sep 8, 2022

Interestingly, the bin-prettier file does not exist and the error is quite different:

image

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'C:\Users\leaumar\.m2\repository\com\hubspot\maven\plugins\prettier-maven-plugin\0.18\prettier-java-1.6.2\node_modules\prettier\bin-prettier.js'

It seems maven has a second problem of trying to parse node:internal/... as a windows path? Hence illegal char : at index 4

@jhaber
Copy link
Member

jhaber commented Sep 8, 2022

Does C:\Users\leaumar\.m2\repository\com\hubspot\maven\plugins\prettier-maven-plugin\0.18\prettier-java-1.6.2 directory exist? If so, do you see a node_modules directory inside of there, with a prettier directory inside of that?

@leaumar
Copy link
Author

leaumar commented Sep 8, 2022

It exists but it's empty
image

@jhaber
Copy link
Member

jhaber commented Sep 8, 2022

Can you try deleting that folder, re-running the Maven plugin from the commandline, and seeing if it gets recreated with some actual files inside?

@leaumar
Copy link
Author

leaumar commented Sep 8, 2022

It created some files this time, but not the files for prettier-plugin-java. The end result is the same error still.

image
image
image

Where are the files in prettier-java-1.6.2 supposed to be downloaded from exactly? Maybe I can't access it or it's redirected to a mirror by corporate config.

@jhaber
Copy link
Member

jhaber commented Sep 19, 2022

Sorry for the delay. prettier-plugin-java is downloaded using npm install:

List<String> command = new ArrayList<>(nodeInstall.getNpmCommand());
command.add("install");
command.add("prettier-plugin-java@" + prettierJavaVersion);

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