Closed thephilwells closed 7 years ago
I ran into the same exact error. Running: Windows 10 x64 Node v6.9.1
I am going to try on linux to see if I can get it to work there.
It actually just gives that error if there's a syntax error in your svelte code, are you sure it's correct? Does it work in the REPL?
For me it works in the REPL and works when I use Windows subsystem for Linux.
I'm getting the same error in Windows 10 x64. Using Windows Subsystem for Linux gives me the same result.
What does the HelloWorld.html
file look like after running the echo
command? It sounds like maybe it's getting borked up at that stage.
<h1>Hello {{name}}</h1>
Same as the text in the example. I've tried copy/pasting it in and typing it in manually.
That happens because echo "<h1>Hello {{name}}</h1>" > HelloWorld.html
results in a UTF-16 LE
-encoded file, while svelte-cli
expects a UTF-8 file.
I guess this should be noted in the documentation. As far as I know, auto-detecting file encodings isn't a very reliable operation.
Okay.
I deleted my HelloWorld.html
file and created a new one without using echo
and it worked fine! Thanks!
We should fix this in the documentation since using echo
is explicitly called for in the tutorial.
As to the encoding, perhaps a flag could be added to the command to specify an encoding different than the default?
You would need to pipe it through iconv since echo
has no option for it on its own.
Since I assume, the encoding is specific to your installation, could you test that, @mrkishi, @keawade?
I think simply noting it in the documentation should be enough. It seems like most other js cli (such as babel and uglifyjs) do not support switching the encoding.
@Ryuno-Ki Yes, iconv would work, of course. Windows users could pipe it through the builtin Out-File
, too:
echo "<h1>Hello {{name}}</h1>" | out-file -encoding utf8 HelloWorld.html
Whew, would never have figured that out, thanks all. I wonder if perhaps the docs should just say 'create a HelloWorld.html file that looks like this' rather than getting into all that – as an OS X user I'd look at command and wonder what on earth was going on.
Lol Windows, always finding new and exciting ways to do things wrong!
To be fair, soon, most Windows dev environments will be closer to Linux than macOS, through WSL. 😛
But I agree with you, removing the echo
mention would be cleaner, as opposed to adding a UTF-8 disclaimer for Windows users.
Have updated the guide, so I'll close this issue
I tried following along with the Getting Started section of the guide.
First, I ran this:
echo "<h1>Hello {{name}}</h1>" > HelloWorld.html
Then I ran this:
svelte compile --format iife .\HelloWorld.html > HelloWorld.js
This caused an empty
HelloWorld.js
file to be generated, and returned the following error:Running on Windows 7, x64 Node v6.5.0 svelte-cli installed globally using npm v3.10.6