SvelteKit 开发服务器未启动
SvelteKit dev server doesn't start
我想试用新的 SvelteKit 替代 Sapper,但我无法启动开发服务器。
我运行:
npm init svelte@next
npm install
npm run dev -- --open
错误:
(node:16570) UnhandledPromiseRejectionWarning: .../Desktop/Programming/Web Development/Svelte/Demo-app/node_modules/@sveltejs/kit/dist/index4.js:262
#map;
^
SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (../Desktop/Programming/Web Development/Svelte/Demo-app/node_modules/@sveltejs/kit/dist/index.js:13:13)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
(node:16570) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:16570) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
我还没有接触过生成的代码。
我知道当服务器启动时无法打开新的浏览器选项卡时会弹出此类错误,但我不知道如何在此处修复它。
- 节点版本:v10.19.0
- OS:Ubuntu 20.04.1 LTS,64 位
- 浏览器:Firefox 83.0(64 位)
- 代理:打嗝套件
我猜您正在尝试制作模板并使用模板语法
{#map bla bla}
那么错误可能只是 map
不受支持,您可能必须切换到 #each
{#each expression as name}...{/each}
我猜 #map
是从节点 12 开始支持的一些 private class field
。
您可以尝试使用节点 12 或更高版本。
我想试用新的 SvelteKit 替代 Sapper,但我无法启动开发服务器。
我运行:
npm init svelte@next
npm install
npm run dev -- --open
错误:
(node:16570) UnhandledPromiseRejectionWarning: .../Desktop/Programming/Web Development/Svelte/Demo-app/node_modules/@sveltejs/kit/dist/index4.js:262
#map;
^
SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (../Desktop/Programming/Web Development/Svelte/Demo-app/node_modules/@sveltejs/kit/dist/index.js:13:13)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
(node:16570) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:16570) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
我还没有接触过生成的代码。
我知道当服务器启动时无法打开新的浏览器选项卡时会弹出此类错误,但我不知道如何在此处修复它。
- 节点版本:v10.19.0
- OS:Ubuntu 20.04.1 LTS,64 位
- 浏览器:Firefox 83.0(64 位)
- 代理:打嗝套件
我猜您正在尝试制作模板并使用模板语法
{#map bla bla}
那么错误可能只是 map
不受支持,您可能必须切换到 #each
{#each expression as name}...{/each}
我猜 #map
是从节点 12 开始支持的一些 private class field
。
您可以尝试使用节点 12 或更高版本。