After a little investigation, it appears that when you use the -npm flag, it currently always compiles your code with Haxe 3.4.7. So the compiler errors that you are getting are likely because some code in your project is expecting Haxe 4, and Haxe 3.4.7 simply doesn’t understand it. This is an unfortunate downside of using the -npm flag.
When you use the -npm flag, it generates a package.json file, which includes a dependency on the haxe npm module. The package.json template has a haxeDependencies section which hard-codes Haxe 3.4.7, and that module will download a completely separate Haxe compiler than the one that is normally used when you don’t specify the -npm flag.
You can make it use a newer Haxe compiler if you provide a custom template for package.json using the <template/> tag in your project.xml.
I have several samples for using custom templates, but not one specifically for the package.json file when using the -npm flag. However, here’s one that replaces index.html, which is similar enough:
It should be very similar for a custom package.json, but where exactly you place your custom package.json is slightly different. While index.html should be at custom-templates/html5/template/index.html, package.json should be here instead: custom-templates/html5/npm/package.json. The path is figured out by looking where the files exist inside Lime. Here’s a link to the html5 template files in the Lime repository:
And here’s a link to the package.json file with the haxe version line highlighted:
You’d just change that line to specify a newer version in your copy of the template file. It will still download a separate Haxe compiler, but you can at least ensure that it matches the version of Haxe that you prefer. Unfortunately, there’s no way to tell npm to use the system Haxe compiler instead.
Thanks for the resources! I confirmed that the template files are loaded by using a custom index.html and I no longer see the --macro errors, but I have the one generic error:
I tried -verbose when compiling, but that’s still all it says. Do I have to add more info to the package.json file or are there other things I can test?