jmjuanes/siimple

Bug: could not run npx siimple -c -o without changing a file in node_modules

pepijnmm opened this issue · 2 comments

Describe the issue

when I tried to run the setup commands following https://siimple.xyz/getting-started/
I got the following error on "npx siimple -c ./siimple.config.mjs -o ./output.css"
see screenshot.

To reproduce

for me, it just happened after doing the second step.
my npm is 8.19.2
node v16.13.0

Screenshots

image

What browser(s) are you seeing the problem on?

No response

What version of siimple are you using?

4.3.0(according to package/package-lock)

Additional context

I could "fix" it by reading a bit on https://stackoverflow.com/a/70057245/4769837
where I read Imports can only do file:// and data://.
So I changed where the error came from on siimple/cli/index.js from:

    return import(configPath).then(rawConfig => rawConfig.default);

to:

    return import("file://" + configPath).then(rawConfig => rawConfig.default);

which fixed it but of course not a great solution.

Hello @pepijnmm.

Instead of concatenating "file://" to the configuration path we can use url.pathToFileURL:

return import(url.pathToFileURL(configPath)).then(rawConfig => rawConfig.default);

As I see in the documentation is the recommended way when using absolute paths with import https://nodejs.org/api/esm.html#file-urls.

Hello @pepijnmm I have just published v4.3.1 with the patch for your issue. Now it should work as expected, but if the issue persists please feel free to reopen the issue.

Thanks!!