前提
vscodeでvue3の開発環境を構築しています。
npm init vue@latest --save-dev
npm install --save-dev
npm run dev
の順で実行後に下記エラーが発生しました。
package.json内では
このようにviteを起動するようになっているようです。
"scripts": {
"dev": "vite"
}
実現したいこと
viteを認識し、開発用サーバーを起動したい
ご教授いただけないでしょうか。
発生している問題・エラーメッセージ
failed to load config from C:\●●●\●●●\●●●\●●●\Vue学習\hello-vue\vite.config.ts error when starting dev server: Error: Cannot find module 'node:url' Require stack: - C:\●●●\●●●\●●●\JS_practice\Vue学習\hello-vue\vite.config.ts - C:\●●●\●●●\●●●\JS_practice\Vue学習\hello-vue\node_modules\vite\dist\node\chunks\dep-4da11a5e.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15) at Function.Module._load (internal/modules/cjs/loader.js:745:27) at Module.require (internal/modules/cjs/loader.js:961:19) at require (internal/modules/cjs/helpers.js:92:18) at Object.<anonymous> (C:\●●●\●●●\●●●\JS_practice\Vue学習\hello-vue\vite.config.ts:32:23) at Module._compile (internal/modules/cjs/loader.js:1072:14) at Object._require.extensions.<computed> [as .js] (file:///C:/●●●/●●●/●●●/JS_practice/Vue%E5%AD%A6%E7%BF%92/hello-vue/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:63537:24) at Module.load (internal/modules/cjs/loader.js:937:32) at Function.Module._load (internal/modules/cjs/loader.js:778:12) at Module.require (internal/modules/cjs/loader.js:961:19) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! hello-vue@0.0.0 dev: `vite` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the hello-vue@0.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:\●●●\●●●\AppData\Roaming\npm-cache\_logs\2022-10-15T10_31_57_181Z-debug.log
該当のソースコード
Typescript vite.config.ts
1import { fileURLToPath, URL } from 'node:url' 2 3import { defineConfig } from 'vite' 4import vue from '@vitejs/plugin-vue' 5 6// https://vitejs.dev/config/ 7export default defineConfig({ 8 plugins: [vue()], 9 resolve: { 10 alias: { 11 '@': fileURLToPath(new URL('./src', import.meta.url)) 12 } 13 } 14}) 15
試したこと
エラー内容を確認し、vite.config.ts内の 'node:url'を'./node_modules'に
してみたのですが、間違っているようで、この変更した行がエラーと指摘されました。
補足情報(FW/ツールのバージョンなど)
・ npm v6.14.14
・ node v14.17.5
・ vite 3.1.8

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/10/16 04:34