Svelte 运行 dev 即使在全新安装和 node_modules 重新安装后也无法工作
Svelte run dev not working even after fresh install and node_modules reinstall
我清理安装的 nodejs 并使用 npx degit sveltejs/template LeanFire
创建了一个 svelte 项目,然后 运行 cd LeanFire && npm install
。多次尝试修复后,我在 运行 npm run dev
.
时仍然遇到相同的错误
D:\Design & Code\LeanFire>npm run dev
> svelte-app@1.0.0 dev
> rollup -c -w
'Code\LeanFire\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'D:\rollup\dist\bin\rollup'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
这是我的 package.json
{
"name": "svelte-app",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv public --no-clear"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"rollup": "^2.3.4",
"rollup-plugin-css-only": "^3.1.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-svelte": "^7.0.0",
"rollup-plugin-terser": "^7.0.0",
"svelte": "^3.0.0"
},
"dependencies": {
"sirv-cli": "^1.0.0"
}
}
看来 npm 遇到了麻烦?我删除了 node_modules,然后改用 pnpm,然后 运行 pnpm install
然后 pnpm run dev
。由于某种原因,它起作用了!?
我清理安装的 nodejs 并使用 npx degit sveltejs/template LeanFire
创建了一个 svelte 项目,然后 运行 cd LeanFire && npm install
。多次尝试修复后,我在 运行 npm run dev
.
D:\Design & Code\LeanFire>npm run dev
> svelte-app@1.0.0 dev
> rollup -c -w
'Code\LeanFire\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'D:\rollup\dist\bin\rollup'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
这是我的 package.json
{
"name": "svelte-app",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv public --no-clear"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"rollup": "^2.3.4",
"rollup-plugin-css-only": "^3.1.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-svelte": "^7.0.0",
"rollup-plugin-terser": "^7.0.0",
"svelte": "^3.0.0"
},
"dependencies": {
"sirv-cli": "^1.0.0"
}
}
看来 npm 遇到了麻烦?我删除了 node_modules,然后改用 pnpm,然后 运行 pnpm install
然后 pnpm run dev
。由于某种原因,它起作用了!?