cannot use import statement outside a module
just pushed my first solidstart app to azure cloud but vinxi start is failing. app works fine in local dev mode.
i'm using github actions to deploy to azure app service.
14 Replies
have you tried renaming your files to *.mjs instead of *.js? That appears to be what the error is about.
NodeJS won't process JS files with ES Module "import" statements without an MJS extensios. Either use require with JS files or change them to MJS files.
seen the hundreds of suggestions on stackoverflow for this error, but I figure I should not change anything since I'm just using the Basic template created by npm init solid@latest
i will try it though
also, looks like GitHub actions is using Node v18.17. Are you using Node 18 locally or another version?
actually there are no js files in the Basic template
oooh good catch
i'm using 18.11 locally
can you share a link to your project?
sure...i'll make it public...
GitHub
GitHub - webmandman/betasolid-02
Contribute to webmandman/betasolid-02 development by creating an account on GitHub.
the problem is obviously coming from the vixni dependency.
@webmandman I would try bumping the Node version in your YAML deploy script. Not sure what else to try...
ok
I don't understand how vinxi and citty are affected in start up process in the production but not in local dev mode.
I can run vinxi start in local env and the site starts up right away.
yeah that's the rub for sure, doesn't make any sense as the module in question is doing EXACTLY what the error is asking for... the file in question is .mjs and the package.json for that library has "type":"module" in it.
bumping to a newer version of Node, like v20 in the container might fix things, but doesn't really make sense that it's happening at all.
the only thing I can think is GitHub actions or the Docker container you're pulling has some strange default configuration applied to the environment.
could also try using something other than "ubuntu-latest" to build the container from. Something like debian or even alpine.
did you have type: module in your package.json?
I do.
i found that many packages are setup same as vinxi amd citty. doesnt make sense why it would break with that citty package.