category icon
2021-11-25
JavaScript - Nuxt2/Bridge

Nuxt Bridge 導入

nuxt2
profile
hikaru
Software Developer / DIY'er
shell
> npx create-nuxt-app my-app

create-nuxt-app v3.7.1
✨  Generating Nuxt.js project in my-app
? Project name: my-app
? Programming language: TypeScript
? Package manager: Npm
? UI framework: None
? Nuxt.js modules: Progressive Web App (PWA)
? Linting tools: (Press <space> to select, <a> to toggle all, <i> to invert selection)
? Testing framework: None
? Rendering mode: Single Page App
? Deployment target: Static (Static/Jamstack hosting)
? Development tools: (Press <space> to select, <a> to toggle all, <i> to invert selection)
? What is your GitHub username? hikaru
? Version control system: Git

> cd my-app

package-lock.jsonnode_modules.nuxt フォルダを削除

shell
# nuxtパッケージを削除
> npm uninstall nuxt

# nuxt-edgeとbridgeパッケージを追加
> npm install nuxt-edge
> npm install -D @nuxt/bridge@npm:@nuxt/bridge-edge
diff
- "scripts": {
-   "dev": "nuxt",
-   "build": "nuxt build",
-   "start": "nuxt start",
-   "generate": "nuxt generate"
- },
+ "scripts": {
+  "dev": "nuxi dev",
+  "build": "nuxi build",
+  "start": "node .output/server/index.mjs",
+  "generate": "nuxi generate"
+},