現象1

画面は真っ白で、ブラウザコンソールに下記が表示されました。

Failed to load module script: Expected a JavaScript module script
 but the server responded with a MIME type of "text/html".
 Strict MIME type checking is enforced for module scripts per HTML spec.
entry.js:1
client:1

.output/public/index.html

動かないコード

entry.jsのパスが不正で存在しない。

<!DOCTYPE html>
<html >
<head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="modulepreload" as="script" crossorigin href="/_nuxt/Users/xxxx/workspace/nuxt-app-origin_space/node_modules/nuxt/dist/app/entry.js">
<script type="module" src="/_nuxt/@vite/client" crossorigin></script>
<script type="module" src="/_nuxt/Users/xxxx/workspace/nuxt-app-origin_space/node_modules/nuxt/dist/app/entry.js" crossorigin></script></head>
動くコード
<!DOCTYPE html>
<html >
<head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/_nuxt/entry.2926e0a3.css">
<link rel="modulepreload" as="script" crossorigin href="/_nuxt/entry.f4dc66b3.js">
<link rel="prefetch" as="style" href="/_nuxt/default.8abbd0b8.css">
<link rel="prefetch" as="script" crossorigin href="/_nuxt/default.bc62d507.js">
<link rel="prefetch" as="script" crossorigin href="/_nuxt/display.82227901.js">
<link rel="prefetch" as="script" crossorigin href="/_nuxt/i18n.config.dfb10aee.js">
<script type="module" src="/_nuxt/entry.f4dc66b3.js" crossorigin></script></head>

現象2

generateに失敗

% yarn generate

 WARN  (inject plugin) rollup-plugin-inject:
 failed to parse /Users/xxxx/workspace/nuxt-app-origin_space/.nuxt/dist/server/client.manifest.mjs.
 Consider restricting the plugin to particular files via options.include

 ERROR  RollupError: Expected ';', got 'module' (Note that you need plugins to import files that are not JavaScript)                            nitro 16:34:28

16:     "file": "/Users/xxxx/workspace/nuxt-app-origin_space/node_modules/nuxt/dist/app/entry.js"
17:   }
18: }module": true,
     ^
19:     "prefetch": true,
20:     "preload": true,

 ERROR  Expected ';', got 'module' (Note that you need plugins to import files that are not JavaScript)                                               16:34:28

  at error (node_modules/rollup/dist/es/shared/parseAst.js:337:30)
  at nodeConverters (node_modules/rollup/dist/es/shared/parseAst.js:2090:9)
  at convertNode (node_modules/rollup/dist/es/shared/parseAst.js:975:12)
  at convertProgram (node_modules/rollup/dist/es/shared/parseAst.js:966:48)
  at parseAstAsync (node_modules/rollup/dist/es/shared/parseAst.js:2156:20)
  at async Module.tryParseAsync (node_modules/rollup/dist/es/shared/node-entry.js:13499:21)
  at async Module.setSource (node_modules/rollup/dist/es/shared/node-entry.js:13080:35)
  at async ModuleLoader.addModuleSource (node_modules/rollup/dist/es/shared/node-entry.js:17722:13) 

 ERROR  Expected ';', got 'module' (Note that you need plugins to import files that are not JavaScript)                                               16:34:28

原因

% yarn dev

を止めてなかったからでした。
Nuxt2では、generateは成功して、devがおかしくなったけど、Nuxt3では正常に終了してしまう。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です