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.
2024-01-22T23:37:36.595785015Z > start
2024-01-22T23:37:36.595807615Z > vinxi start
2024-01-22T23:37:36.595811515Z
2024-01-22T23:37:38.142761667Z (node:108) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
2024-01-22T23:37:38.142842867Z (Use `node --trace-warnings ...` to show where the warning was created)
2024-01-22T23:37:38.155024316Z /home/site/wwwroot/node_modules/.bin/vinxi:2
2024-01-22T23:37:38.155051816Z import { defineCommand, runMain } from "citty";
2024-01-22T23:37:38.155098217Z ^^^^^^
2024-01-22T23:37:38.155103217Z
2024-01-22T23:37:38.155106817Z SyntaxError: Cannot use import statement outside a module
2024-01-22T23:37:38.155110617Z at internalCompileFunction (node:internal/vm:73:18)
2024-01-22T23:37:38.155114217Z at wrapSafe (node:internal/modules/cjs/loader:1178:20)
2024-01-22T23:37:38.155118017Z at Module._compile (node:internal/modules/cjs/loader:1220:27)
2024-01-22T23:37:38.155121717Z at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
2024-01-22T23:37:38.155125417Z at Module.load (node:internal/modules/cjs/loader:1119:32)
2024-01-22T23:37:38.155128917Z at Module._load (node:internal/modules/cjs/loader:960:12)
2024-01-22T23:37:38.155132617Z at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
2024-01-22T23:37:38.155136317Z at node:internal/main/run_main_module:23:47
2024-01-22T23:37:38.161784444Z
2024-01-22T23:37:38.161805044Z Node.js v18.17.1
2024-01-22T23:37:36.595785015Z > start
2024-01-22T23:37:36.595807615Z > vinxi start
2024-01-22T23:37:36.595811515Z
2024-01-22T23:37:38.142761667Z (node:108) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
2024-01-22T23:37:38.142842867Z (Use `node --trace-warnings ...` to show where the warning was created)
2024-01-22T23:37:38.155024316Z /home/site/wwwroot/node_modules/.bin/vinxi:2
2024-01-22T23:37:38.155051816Z import { defineCommand, runMain } from "citty";
2024-01-22T23:37:38.155098217Z ^^^^^^
2024-01-22T23:37:38.155103217Z
2024-01-22T23:37:38.155106817Z SyntaxError: Cannot use import statement outside a module
2024-01-22T23:37:38.155110617Z at internalCompileFunction (node:internal/vm:73:18)
2024-01-22T23:37:38.155114217Z at wrapSafe (node:internal/modules/cjs/loader:1178:20)
2024-01-22T23:37:38.155118017Z at Module._compile (node:internal/modules/cjs/loader:1220:27)
2024-01-22T23:37:38.155121717Z at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
2024-01-22T23:37:38.155125417Z at Module.load (node:internal/modules/cjs/loader:1119:32)
2024-01-22T23:37:38.155128917Z at Module._load (node:internal/modules/cjs/loader:960:12)
2024-01-22T23:37:38.155132617Z at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
2024-01-22T23:37:38.155136317Z at node:internal/main/run_main_module:23:47
2024-01-22T23:37:38.161784444Z
2024-01-22T23:37:38.161805044Z Node.js v18.17.1
14 Replies
Only Cliches
Only Cliches5mo ago
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.
webmandman
webmandman5mo ago
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
Only Cliches
Only Cliches5mo ago
also, looks like GitHub actions is using Node v18.17. Are you using Node 18 locally or another version?
webmandman
webmandman5mo ago
actually there are no js files in the Basic template oooh good catch i'm using 18.11 locally
Only Cliches
Only Cliches5mo ago
can you share a link to your project?
webmandman
webmandman5mo ago
sure...i'll make it public...
webmandman
webmandman5mo ago
GitHub
GitHub - webmandman/betasolid-02
Contribute to webmandman/betasolid-02 development by creating an account on GitHub.
Only Cliches
Only Cliches5mo ago
the problem is obviously coming from the vixni dependency.
Only Cliches
Only Cliches5mo ago
No description
Only Cliches
Only Cliches5mo ago
@webmandman I would try bumping the Node version in your YAML deploy script. Not sure what else to try...
webmandman
webmandman5mo ago
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.
Only Cliches
Only Cliches5mo ago
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.
lxsmnsyc
lxsmnsyc5mo ago
did you have type: module in your package.json?
webmandman
webmandman5mo ago
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.