我的问题
我挣扎了三天。看来HMR不起作用了。更确切地说,我想建筑是失败的,当它是通过HMR完成。
在第一个开发项目开始时,它可以工作。但是,当我在文件中进行更改并保存它时,它不会应用更改。在保存我的更改而没有反映浏览器的结果后,代码一直在闪烁。
但奇怪的是,它只在保存svelte.config.js文件之后才会反映变化。在我保存svelte.config.js之后,开发服务器就会重新启动,代码的闪烁效果就会停止并反映更改。我首先想,“也许只有在服务器重新启动之后,它才能工作吗..?”但事实并非如此,当我浏览vite.config.js时,变化并没有得到反映。同样的闪烁效果。
现在,每次在任何文件中进行更改时,我都必须保存svelte.config.js文件,而不知道原因。(所以每次做painful......and都要花几秒钟时间)
我录下了我的屏幕
https://www.loom.com/share/71dab382a20547919e07bf410d49fc9d
我的package.json
{
"name": "sveltekit-typescript-showcase",
"version": "1.0.0",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"build:types": "openapi-typescript https://vskodzianevmhpqzmjqd.supabase.co/rest/v1/?apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZza29kemlhbmV2bWhwcXptanFkIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NTI0Mzg0MTAsImV4cCI6MTk2ODAxNDQxMH0.pqf9e6G8pcMxCdVVIipD-RXJrYV-9RJK_qWruTkjGAg --output src/types/supabase.ts",
"gen-type-dev": "supabase gen types typescript --db-url postgres://postgres:HappyHyein66!@db.jgxpeedixksinkdlpfwp.supabase.co:6543/postgres",
"package": "vite package",
"preview": "vite preview"
},
"devDependencies": {
"@supabase/supabase-js": "^1.35.3",
"@types/lodash": "^4.14.186",
"carbon-components-svelte": "^0.65.0",
"openapi-typescript": "5.4.0",
"prettier": "^2.6.2",
"sass": "^1.52.2",
"svelte": "^3.46.6",
"svelte-check": "^2.4.6",
"svelte-preprocess": "^4.10.5",
"tslib": "^2.3.1",
"typescript": "~4.6.3",
"vite": "^3.1.7",
"@sveltejs/kit": "^1.0.0-next.359"
},
"type": "module",
"dependencies": {
"@supabase/supabase-js": "^1.35.3",
"@sveltejs/adapter-vercel": "^1.0.0-next.80",
"@sveltejs/kit": "^1.0.0-next.359",
"base64-arraybuffer": "^1.0.2",
"carbon-icons-svelte": "^11.1.0",
"svelte": "^3.46.6",
"encoding": "^0.1.13",
"lodash": "^4.17.21",
"nvm": "^0.0.4",
"supabase": "^0.5.0"
}
}svelte.config.js
import vercel from '@sveltejs/adapter-vercel';
import { resolve } from 'path';
import preprocess from 'svelte-preprocess';
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: preprocess(),
alias: {
$lib: resolve('./src/lib'),
$models: resolve('./src/models'),
},
kit: {
adapter: vercel()
},
};
export default config;vite.config.js
import { sveltekit } from '@sveltejs/kit/vite';
import { resolve } from 'path';
const config = {
plugins: [sveltekit()],
resolve: {
alias: {
$lib: resolve( './src/lib'),
$models: resolve('./src/models'),
$types: resolve('./src/types/index.ts')
},
},
server: {
fs: {
// Allow serving files from one level up to the project root
allow: ['..'],
},
},
}
export default config;vite.config.js
import { sveltekit } from '@sveltejs/kit/vite';
import { resolve } from 'path';
const config = {
plugins: [sveltekit({
preprocess: preprocess(),
alias: {
$lib: resolve('./src/lib'),
$models: resolve('./src/models'),
},
kit: {
adapter: vercel()
},
})],
resolve: {
alias: {
$lib: resolve( './src/lib'),
$models: resolve('./src/models'),
$types: resolve('./src/types/index.ts')
},
},
server: {
fs: {
// Allow serving files from one level up to the project root
allow: ['..'],
},
},
}
export default config;// Raw
6:26:23 PM [vite] server restarted.
➜ Local: http://127.0.0.1:5173/
➜ Network: use --host to expose
The following Vite config options will be overridden by SvelteKit:
- resolve.alias.$lib
6:26:24 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/src/lib/component/Sidebar.svelte:111:0 Unused CSS selector ".menu-icon.home"
6:26:24 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/src/lib/component/Sidebar.svelte:123:0 Unused CSS selector ".menu-icon.hanger"
6:26:26 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/ComposedModal/ComposedModal.svelte:153:2 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:26:26 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/ComposedModal/ModalBody.svelte:9:0 A11y: noninteractive element cannot have positive tabIndex value
6:26:26 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/CodeSnippet/CodeSnippet.svelte:221:4 A11y: noninteractive element cannot have positive tabIndex value
6:26:27 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/DataTable/DataTableSkeleton.svelte:66:2 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:26:27 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/FileUploader/FileUploaderButton.svelte:63:0 A11y: noninteractive element cannot have positive tabIndex value
6:26:27 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/FileUploader/FileUploaderDropContainer.svelte:84:2 A11y: noninteractive element cannot have positive tabIndex value
6:26:27 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/ListBox/ListBoxField.svelte:46:0 A11y: noninteractive element cannot have positive tabIndex value
6:26:27 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/Modal/Modal.svelte:242:4 A11y: noninteractive element cannot have positive tabIndex value
6:26:27 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/NumberInput/NumberInput.svelte:156:0 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:26:28 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/Search/Search.svelte:104:4 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:26:28 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/StructuredList/StructuredListRow.svelte:15:2 A11y: noninteractive element cannot have positive tabIndex value
6:26:28 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/Tile/SelectableTile.svelte:56:0 A11y: noninteractive element cannot have positive tabIndex value
6:26:28 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/TextArea/TextArea.svelte:62:0 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:26:28 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/TimePicker/TimePicker.svelte:55:0 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:26:28 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/TextInput/TextInput.svelte:103:0 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:26:28 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/TextInput/PasswordInput.svelte:97:0 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:26:28 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/Tooltip/Tooltip.svelte:252:6 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:26:29 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/UIShell/SideNav.svelte:52:2 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:26:29 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/UIShell/HeaderSearch.svelte:64:7 A11y: Elements with the ARIA role "combobox" must have the following attributes defined: "aria-controls", "aria-expanded"
6:26:29 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/TreeView/TreeViewNodeList.svelte:135:6 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
data! {}
data! {}
files in the public directory are served at the root path.
Instead of /static/icon/customer.svg, use /icon/customer.svg.
files in the public directory are served at the root path.
Instead of /static/icon/add.svg, use /icon/add.svg.
files in the public directory are served at the root path.
Instead of /static/icon/schedule.svg, use /icon/schedule.svg.
6:26:34 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/src/lib/component/Sidebar.svelte:111:0 Unused CSS selector ".menu-icon.home"
6:26:34 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/src/lib/component/Sidebar.svelte:123:0 Unused CSS selector ".menu-icon.hanger"
data! {}
6:26:37 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/ComposedModal/ComposedModal.svelte:153:2 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:26:37 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/ComposedModal/ModalBody.svelte:9:0 A11y: noninteractive element cannot have positive tabIndex value
6:26:37 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/CodeSnippet/CodeSnippet.svelte:221:4 A11y: noninteractive element cannot have positive tabIndex value
6:26:38 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/DataTable/DataTableSkeleton.svelte:66:2 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
onents-svelte/src/Tooltip/Tooltip.svelte:252:6 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:26:43 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/TimePicker/TimePicker.svelte:55:0 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:26:43 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/UIShell/SideNav.svelte:52:2 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:26:43 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/UIShell/HeaderSearch.svelte:64:7 A11y: Elements with the ARIA role "combobox" must have the following attributes defined: "aria-controls", "aria-expanded"
6:26:44 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/TreeView/TreeViewNodeList.svelte:135:6 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:36:53 PM [vite] changed tsconfig file detected: C:\Users\Jooyeon\Downloads\modeny-svelte-typescript\tsconfig.json - Clearing cache and forcing full-reload to ensure TypeScript is compiled with updated config values.
6:36:54 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/src/lib/component/Sidebar.svelte:111:0 Unused CSS selector ".menu-icon.home"
6:36:54 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/src/lib/component/Sidebar.svelte:123:0 Unused CSS selector ".menu-icon.hanger"
6:36:56 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/ComposedModal/ComposedModal.svelte:153:2 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:36:56 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/ComposedModal/ModalBody.svelte:9:0 A11y: noninteractive element cannot have positive tabIndex value
6:36:56 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/CodeSnippet/CodeSnippet.svelte:221:4 A11y: noninteractive element cannot have positive tabIndex value
6:36:56 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/DataTable/DataTableSkeleton.svelte:66:2 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:36:56 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/FileUploader/FileUploaderButton.svelte:63:0 A11y: noninteractive element cannot have positive tabIndex value
6:36:56 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/FileUploader/FileUploaderDropContainer.svelte:84:2 A11y: noninteractive element cannot have positive tabIndex value
6:36:57 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/ListBox/ListBoxField.svelte:46:0 A11y: noninteractive element cannot have positive tabIndex value
6:36:57 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/Modal/Modal.svelte:242:4 A11y: noninteractive element cannot have positive tabIndex value
6:36:57 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/NumberInput/NumberInput.svelte:156:0 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:36:57 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/Search/Search.svelte:104:4 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:36:58 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/StructuredList/StructuredListRow.svelte:15:2 A11y: noninteractive element cannot have positive tabIndex value
6:36:58 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/TextInput/TextInput.svelte:103:0 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:36:58 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/TextInput/PasswordInput.svelte:97:0 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:36:58 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/Tile/SelectableTile.svelte:56:0 A11y: noninteractive element cannot have positive tabIndex value
6:36:58 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/TimePicker/TimePicker.svelte:55:0 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:36:58 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/TextArea/TextArea.svelte:62:0 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:36:58 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/Tooltip/Tooltip.svelte:252:6 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:36:58 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/UIShell/SideNav.svelte:52:2 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:36:59 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/UIShell/HeaderSearch.svelte:64:7 A11y: Elements with the ARIA role "combobox" must have the following attributes defined: "aria-controls", "aria-expanded"
6:36:59 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/TreeView/TreeViewNodeList.svelte:135:6 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
data! {}
files in the public directory are served at the root path.
Instead of /static/icon/customer.svg, use /icon/customer.svg.
files in the public directory are served at the root path.
Instead of /static/icon/add.svg, use /icon/add.svg.
files in the public directory are served at the root path.
Instead of /static/icon/schedule.svg, use /icon/schedule.svg.
6:37:01 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/src/lib/component/Sidebar.svelte:111:0 Unused CSS selector ".menu-icon.home"
6:37:01 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/src/lib/component/Sidebar.svelte:123:0 Unused CSS selector ".menu-icon.hanger"
data! {}
6:37:04 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/ComposedModal/ComposedModal.svelte:153:2 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.
6:37:04 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/ComposedModal/ModalBody.svelte:9:0 A11y: noninteractive element cannot have positive tabIndex value
6:37:04 PM [vite-plugin-svelte] C:/Users/Jooyeon/Downloads/modeny-svelte-typescript/node_modules/carbon-components-svelte/src/CodeSnippet/CodeSnippet.svelte:221:4 A11y: noninteractive element cannot have positive tabIndex value
npm WARN deprecated nvm@0.0.4: This is NOT the correct nvm. Visit https://nvm.sh and use the curl command to install it.
added 294 packages, and audited 295 packages in 16s
24 packages are looking for funding
run `npm fund` for details
4 vulnerabilities (1 moderate, 3 critical)
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.发布于 2022-11-10 10:53:00
查看这里最简单的package.json文件(https://stackblitz.com/edit/sveltejs-kit-template-default-wab2ls?file=package.json&terminal=dev),它位于svelte的头版(https://kit.svelte.dev/),我发现列表上有@type/cookie,而不是我的。
我记得有一次VScode显示了一条关于它的错误消息,所以我把它添加到列表中,然后重新安装,它工作了……
https://stackoverflow.com/questions/74373090
复制相似问题