1

I'm trying to get started with Svelte. All guides I've found list two commands as all that's required:

npm install
npm run dev

However, in Windows 10, with a fresh install of Node 12.16.3 LTS and NPM 6.14.4 (installed with NVM-Windows after uninstalling NodeJS completely, per this guide), once I hit npm run dev, I get the following errors:

$ npm run dev

> svelte-app@1.0.0 dev C:\Users\Matthew\Desktop\SvelteTest
> rollup -c -w

'rollup' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! svelte-app@1.0.0 dev: `rollup -c -w`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the svelte-app@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Matthew\AppData\Roaming\npm-cache\_logs\2020-05-23T02_58_39_101Z-debug.log

"Hmm... Okay, that's weird, since every tutorial I've watched and guide I've read has this including in npm install, but, no worries, I'll just install rollup," I think to myself... A quick npm install -g rollup later, and the error is fixed! Good start. Sadly, this doesn't last too long, since now I run into the following issue:

$ npm run dev

> svelte-app@1.0.0 dev C:\Users\Matthew\Desktop\SvelteTest
> rollup -c -w

rollup v2.10.7
bundles src/main.js → public\build\bundle.js...
LiveReload enabled
created public\build\bundle.js in 338ms

> svelte-app@1.0.0 start C:\Users\Matthew\Desktop\SvelteTest
> sirv public "--dev"

'sirv' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! svelte-app@1.0.0 start: `sirv public "--dev"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the svelte-app@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Matthew\AppData\Roaming\npm-cache\_logs\2020-05-23T03_00_53_008Z-debug.log

This time, no amount of npm install -g sirv will work. Is there a step I'm missing to getting this project to run?


Some notes:

  • I can get it to work in WSL Ubuntu 18.04 LTS, but would prefer not to have to use WSL if at all possible.

    • I don't see anything anywhere online that says that Windows isn't supported... is it not? Am I not looking hard enough?
  • When I run npm install -g rollup, I see the following warnings:

    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules\rollup\node_modules\fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
    

    I assume that, since this is listed as an optional dependency, it is not the source of the issue. Nonetheless, it feels silly not to bring it up — just in case. These same warnings appear during npm install.

  • The files npm-cahce\_logs\[datetime]-debug.log don't contain any usefull information as far as I can tell, they simply say, "sirv public "--dev"Failed to start exec script" followed by a stack-trace.

  • After the second error, the program does not automatically terminate — but it is not available at localhost:5000.

  • I had my files in OneDrive for a while (they're now on my Desktop, which is not synced or tracked in any way), and OneDrive was upset about the files in node_modules/.bin, saying that they "couldn't be synced because of their name or type" -- this leads me to believe that perhaps this is a wider Windows/MS problem? Somehow, I doubt this is the issue.

  • Just to double check, I tried all of my aforementioned steps in Git Bash (my preferred terminal on Windows), CMD, and Powershell -- all exhibited the same behaviour.


Thanks in advance.

matthew-e-brown
  • 2,837
  • 1
  • 10
  • 29

1 Answers1

13

Ah, well... I feel silly now. Same issue as with Rollup — I had to install it with npm globally. But, I missed that there's both sirv and sirv-cli on NPM.

Running npm install -g sirv-cli fixed my issue.

However... I would still like to know why I don't see this issue mentioned anywhere in any guide anywhere else with all the rest of Svelte's Hello World stuff. Any information would be greatly appreciated!

matthew-e-brown
  • 2,837
  • 1
  • 10
  • 29
  • I looked at the 'official' svelte boilerplate and they have sirv-cli on the dependencies: https://github.com/sveltejs/template. But anyway: congratz that you found it and each error solved builds up experience :) – Andreas Dolk May 23 '20 at 06:36
  • 1
    You shouldn't have to install things globally. Ordinarily, when you do `npm run [script]`, it prepends `node_modules/.bin` to your `$PATH` so that if the command references a local binary (like `rollup` or `sirv`) it will resolve to e.g. `node_modules/.bin/rollup`, which in turn is symlinked by npm to the relevant file. It sounds like that part of npm's behaviour isn't working for your particular setup – Rich Harris May 27 '20 at 13:57
  • @RichHarris Thanks for the info! I'll look into that part more specifically. – matthew-e-brown May 27 '20 at 20:01
  • @matthew-e-brown any chance you're using scoop.sh ? Because if you do it would be caused by scoop update which is what just happened here. Hope it helps. – magicbyt3 Jun 19 '20 at 20:09
  • 1
    @v01d No, I'm not, thanks, though :) I think whatever caused the issue was some anomaly with using Git Bash on Windows, which, in a recent update, introduced something along the lines of "closer emulation to Linux consoles" (I forget exactly what the option was, but the description was something along those lines). I went back and tried again without the global `sirv-cli` install, and it worked fine. Just worth noting that, at the moment, I think this is a beta feature of Git For Windows. – matthew-e-brown Jun 19 '20 at 20:13