运行 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
都不起作用。我是否缺少将此项目推向 运行 的步骤?
一些注意事项:
我可以让它在 WSL Ubuntu 18.04 LTS 中工作,但如果可能的话我宁愿不必使用 WSL。
- 我在网上没有看到任何地方说 Windows 不受支持...不是吗?是我看的不够仔细吗?
当我 运行 npm install -g rollup
时,我看到以下警告:
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"})
我假设,因为这被列为 可选 依赖项,所以它不是问题的根源。尽管如此,不提起它感觉很愚蠢——以防万一。这些相同的警告出现在 npm install
.
期间
据我所知,文件 npm-cahce\_logs\[datetime]-debug.log
不包含任何有用的信息,它们只是说,“sirv public "--dev"
→ Failed to start exec script
”,然后是堆栈跟踪。
第二次错误后,程序不会自动终止 — 但在 localhost:5000
.
处不可用
我的文件在 OneDrive 中有一段时间(它们现在在我的桌面上,没有以任何方式同步或跟踪),OneDrive 对 node_modules/.bin
,说他们 "couldn't be synced because of their name or type"——这让我相信这可能是一个更广泛的 Windows/MS 问题?不知何故,我怀疑这是问题所在。
为了仔细检查,我在 Git Bash(我在 Windows 上的首选终端)、CMD 和 Powershell 中尝试了所有上述步骤 - - 所有人都表现出相同的行为。
提前致谢。
啊,好吧……我现在觉得很傻。与 Rollup 相同的问题——我必须在全局范围内使用 npm
安装它。但是,我错过了 NPM 上同时存在 sirv
和 sirv-cli
的情况。
运行 npm install -g sirv-cli
解决了我的问题。
但是...我仍然想知道为什么我没有在任何其他地方的任何指南中看到这个问题以及 Svelte 的所有其他 Hello World 内容。任何信息将不胜感激!
我正在尝试开始使用 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
都不起作用。我是否缺少将此项目推向 运行 的步骤?
一些注意事项:
我可以让它在 WSL Ubuntu 18.04 LTS 中工作,但如果可能的话我宁愿不必使用 WSL。
- 我在网上没有看到任何地方说 Windows 不受支持...不是吗?是我看的不够仔细吗?
当我 运行
npm install -g rollup
时,我看到以下警告: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"})
我假设,因为这被列为 可选 依赖项,所以它不是问题的根源。尽管如此,不提起它感觉很愚蠢——以防万一。这些相同的警告出现在
npm install
. 期间
据我所知,文件
npm-cahce\_logs\[datetime]-debug.log
不包含任何有用的信息,它们只是说,“sirv public "--dev"
→Failed to start exec script
”,然后是堆栈跟踪。第二次错误后,程序不会自动终止 — 但在
localhost:5000
. 处不可用
我的文件在 OneDrive 中有一段时间(它们现在在我的桌面上,没有以任何方式同步或跟踪),OneDrive 对
node_modules/.bin
,说他们 "couldn't be synced because of their name or type"——这让我相信这可能是一个更广泛的 Windows/MS 问题?不知何故,我怀疑这是问题所在。为了仔细检查,我在 Git Bash(我在 Windows 上的首选终端)、CMD 和 Powershell 中尝试了所有上述步骤 - - 所有人都表现出相同的行为。
提前致谢。
啊,好吧……我现在觉得很傻。与 Rollup 相同的问题——我必须在全局范围内使用 npm
安装它。但是,我错过了 NPM 上同时存在 sirv
和 sirv-cli
的情况。
运行 npm install -g sirv-cli
解决了我的问题。
但是...我仍然想知道为什么我没有在任何其他地方的任何指南中看到这个问题以及 Svelte 的所有其他 Hello World 内容。任何信息将不胜感激!