-
Notifications
You must be signed in to change notification settings - Fork 1
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
Elsa sometimes fails to build #176
Comments
Yeah but the advantage of not compiling the code (i.e. kind of the reason I like ts-node) is because you then don't need to be doing checks (i.e. Makefiles) to test that the generated .js files aren't older than the corresponding .ts files. If we pre-compile the common libraries - we then can end in situations where the rest of the project is compiling/running against JS that is out of date with the TS. I realise ts-node failing is also equally bad! - and agree this is a complete mess - but not sure separately compiling is a big win.. |
Are you sure it isn't picking up the wrong tsc somehow. All invokes need to have |
Whilst I've encountered build problems from the React side (which we have no fixed with the new build tool) - I've never encountered this particular issue on running the backend side (have encountered lots of modules/es6 errors when trying to do the Docker bundling - but that was a separate issue - in terms of literally running ts-node locally I haven't encountered this) |
After removing and reinstalling node and npm, its working for me now. My npm version went from Thanks for helping me debug this! |
Issue
When cloning the project, installing dependencies, and attempting to run the backed with
npm run dev:mac
ornpm run watch:mac
, compilation sometimes fails with an export/import syntax error:This error appears when the backend compiles both
elsa-types
andelsa-constants
. It looks like it is related to how node and ts-node treat CommonJS and ES6 modules.Solution
This seems to be a very difficult error to track down and find the cause of, and after trying many different combinations of
tsconfig.json
andpackage.json
options, I could not find an easy solution. There seems to be a mismatch between CommonJS and ES modules. Simple solutions like adding"esModuleInterop": true
to tsconfig.json or setting"experimentalResolver": true
in"ts-node"
don't work.I can't quite tell whether this is an error with node, ts-node, or typescript, however I think the problem is somewhere in the configuration.
The line prior to the error generates a warning which suggests a potential solution:
(node:32485) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
This would force node and ts-node to use ES modules, however it would require significant restructuring of all the imports in the backend. For example, relative imports would require a
.js
ending.Workaround
A workaround for this issue is to build
elsa-types
andelsa-constants
manually, and reinstall them as dependencies before runningnpm run dev:mac
:This allows ts-node to use the pre-compiled javascript.
I'm not sure why ts-node has an issue with this, but pre-compiling the typescript files fixes the problem. My understanding was that ts-node would use the same
tsconfig.json
astsc
.The text was updated successfully, but these errors were encountered: