运行 Svelte on Windows 10 - 'sirv' 未被识别为命令

Running Svelte on Windows 10 - 'sirv' is not recognized as a command

我正在尝试开始使用 Svelte。我找到的所有指南都列出了两个所需的命令:

npm install
npm run dev

但是,在 Windows 10 中,全新安装了 Node 12.16.3 LTS 和 NPM 6.14.4 (installed with NVM-Windows after uninstalling NodeJS completely, per this guide),一旦我点击 npm run dev,我就会得到以下错误:

$ 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\_logs20-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," 我心想... npm install -g rollup 之后,错误已修复!好的开始。遗憾的是,这不会持续太久,因为现在我 运行 进入以下问题:

$ 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\_logs20-05-23T03_00_53_008Z-debug.log

这一次,再多的 npm install -g sirv 都不起作用。我是否缺少将此项目推向 运行 的步骤?


一些注意事项:


提前致谢。

啊,好吧……我现在觉得很傻。与 Rollup 相同的问题——我必须在全局范围内使用 npm 安装它。但是,我错过了 NPM 上同时存在 sirvsirv-cli 的情况。

运行 npm install -g sirv-cli 解决了我的问题。

但是...我仍然想知道为什么我没有在任何其他地方的任何指南中看到这个问题以及 Svelte 的所有其他 Hello World 内容。任何信息将不胜感激!