Giter Club home page Giter Club logo

starter's Introduction

🪄 Nuxt Starter Templates

Quickly get started with a minimal Nuxt starter template!

Quick start

Head over to nuxt.new to get started quickly.

Usage

You can use nuxi CLI to clone latest template to an empty directory:

$ npx nuxi init [-t,--template=<template>] [<dir>]

Example: Clone v3 to my-app directory:

$ npx nuxi init -t v3 nuxt-app

Templates

Name Description Local Online
v3 Nuxt 3 npx nuxi init nuxt-app Stackblitz / CodeSandbox
module Nuxt Module with Module Builder npx nuxi init my-module -t module -
module-devtools Nuxt Module with Nuxt DevTools integration npx nuxi init my-module -t module-devtools -
layer Nuxt Layer Starter with Extends (experimental) npx nuxi init -t layer -
content Nuxt Content npx nuxi init content-app -t content Stackblitz / CodeSandbox
ui Nuxt UI npx nuxi init nuxt-ui-app -t ui Stackblitz / CodeSandbox
v2-bridge Nuxt 2 + Bridge npx nuxi init nuxt-bridge-app -t v2-bridge Stackblitz / CodeSandbox
v2 Nuxt 2 npx nuxi init nuxt2-app -t v2 Stackblitz / CodeSandbox

Contribution

Each template is maintained in a branch (see all branches). For improvements, please open a Pull Request to each individual branch.

Note: Please avoid commiting lock-files such as yarn.lock and package-lock.json to template branches!

License

MIT - Made with 💚

starter's People

Contributors

acekyd avatar antfu avatar atinux avatar bracketjohn avatar clemcode avatar danielroe avatar pi0 avatar tahul avatar toastal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

starter's Issues

New layer fails typecheck

I created a new layer project using npx nuxi init -t layer and when I run npx nuxi typecheck on the fresh project, there is a failure. You can see the output here:

.playground/nuxt.config.ts:2:3 - error TS2322: Type 'string' is not assignable to type '(string | [(string | undefined)?, ({ [x: string]: any; meta?: { [x: string]: any; name?: string | undefined; } | undefined; giget?: { provider?: string | undefined; force?: boolean | undefined; ... 7 more ...; auth?: string | undefined; } | undefined; overrides?: { ...; } | undefined; } | undefined)?] | undefined)[]'.

2   extends: '..'
    ~~~~~~~

  node_modules/@nuxt/schema/dist/index.d.ts:1135:2
    1135  extends: (string|string|[string, SourceOptions?])[],
          ~~~~~~~
    The expected type comes from property 'extends' which is declared here on type 'InputConfig<NuxtConfig, ConfigLayerMeta>'


Found 1 error in .playground/nuxt.config.ts:2

I'm not a TypeScript expert so I'm not sure how this would be addressed. Maybe just changing to:

extends: ['..']

would fix

Vercel deployment

I've temporarily removed it since was failing on all other branches. We need to add it back only if there is a way to disable preview branches.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

Branch v3
npm
package.json
  • nuxt ^3.12.2
Branch v3-codesandbox
npm
package.json
  • nuxt ^3.12.2
Branch v3-stackblitz
npm
package.json
  • nuxt ^3.12.2
Branch v3-vercel
npm
package.json
  • nuxt ^3.12.2
  • vue ^3.4.29
  • vue-router ^4.3.3
Branch v4-compat
npm
package.json
  • nuxt ^3.12.2
Branch module
npm
package.json
  • @nuxt/kit ^3.12.2
  • @nuxt/devtools ^1.3.3
  • @nuxt/eslint-config ^0.3.13
  • @nuxt/module-builder ^0.7.1
  • @nuxt/schema ^3.12.2
  • @nuxt/test-utils ^3.13.1
  • @types/node ^20.14.2
  • changelogen ^0.5.5
  • eslint ^9.5.0
  • nuxt ^3.12.2
  • vitest ^1.6.0
  • vue-tsc ^2.0.21
playground/package.json
  • nuxt ^3.12.2
Branch doc-driven
npm
package.json
  • @nuxt/content ^2.12.1
  • nuxt ^3.12.2
Branch content
npm
package.json
  • @nuxt/content ^2.12.1
  • nuxt ^3.12.1
Branch v2
npm
package.json
  • core-js ^3.37.1
  • nuxt ^2.17.4
Branch v2-bridge
npm
package.json
  • nuxi 3.12.0
  • nuxt 2.17.4
Branch v2-stackblitz
npm
package.json
  • core-js ^3.37.1
  • nuxt ^2.17.4
Branch v2-codesandbox
npm
package.json
  • nuxt ^2.17.4

  • Check this box to trigger a request for Renovate to run again on this repository

Types are lost when assigned to runtimeConfig

Hi,

My module has options like

type User = {
  name: string;
  age: number;
};

export interface ModuleOptions {
  users: User[]
}

I pass this information to runtime via runtimeConfig

export default defineNuxtModule<ModuleOptions>({
  meta: {
    configKey: 'myModule',
  },
  defaults: {
    users: [],
  },
  setup (options, nuxt) {
    nuxt.options.runtimeConfig.public.myModule = {
      users: options.users,
    }

    const resolver = createResolver(import.meta.url)
    addPlugin(resolver.resolve('./runtime/plugin'))
  }
})

While options.users that is being assigned to runtime config has type (property) ModuleOptions.users: User[],
the runtimeConfig.public.myModule.users has type (property) users: {}[]. It also happens in other files, like in runtime/plugin.ts, for example, when you want to use users from the above example.

As you can see { name: string; age: number; }[] become just {}[]. Is that expected? And if so, how can we improve/adjust these types.

reproduction link: https://stackblitz.com/edit/github-wvc2k7?file=src%2Fmodule.ts

Server handlers added via nuxt/kit fail to import from #imports

I have reproduced an issue that seems to prevent server handlers added via addServerHandler from importing functions exposed via addImportsSources.

See this barebones module https://github.com/marr/nuxt3-module

In src/module.ts I add an imports source, and then add the server handler. When running build with npm run dev:prepare && npm run dev:build, the build errors out with the following:

Error: [unimport] failed to find "wassup" imported from "#imports"

Is there a better approach to provide imports for the handlers?

Should .npmrc be ignored?

I created a Nuxt 3 project with the starter repository (thank you😊).

After I uploaded the project on GitHub as a public repository, GitGuardian warned me not to include .npmrc.

Therefore, it can be better to add .npmrc into .gitignore without removing .npmrc.

Feature: remote repositories

We try to use part of unjs engine to download remote package by this:

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
  extends: ["github:org-name/repo-name"]
});

Rollup issues, there is problem with alias for directories - this is propably connected: nuxt/nuxt#18448

We get some point resolve by using alias config and in debug there is downloaded repo but not linked same like monorepo have.
As we found out - npm isn't init after download and node_modules isn't found.
There are issue by multiple node_modules that will show Error 500 same as there in this topic:
nuxt/nuxt#14928

This engine will be used in future? Nice to add in documentation and when someone search it : https://unstorage.unjs.io/drivers/github

Documentation should say that remote paths aren't available like there right now:
https://github.com/nuxt-contrib/nuxt-extend#parent

This topic is only to have question and add information when someone search for that option

Better default for store integration

awesome @danielroe considered better store default integration 😍
image

Also wondering: is templating like this on initialization supposed to replace a scaffolding solution like create-nuxt-app? I am really missing a wizard like this in the nuxt3 universe. Linting with extends, css preprocessor, git, modules, store :'(

after starter serve, visited page out this error

No response returned from render handler: /__nuxt_error?url=/&statusCode=500&statusMessage=Vite+Error&message=[vite-node]+[ERR_INVALID_URL_SCHEME]+/node_modules/ufo/dist/index.mjs&stack=%3Cpre%3E%3Cspan+class=%22stack+internal%22%3Eat+/node_modules/ufo/dist/index.mjs%3C/span%3E%3C/pre%3E&data

Nuxt module : IDE doesn't recognize vue functions.

Hello,

I create a new Nuxt module :

npx nuxi init -t module my-module

Next, I correct an error with package dependencies changing the vitest version in package.json :

"vitest": "^1.1.0",

I launch the command to prepare the project :

npm i
npm run dev:prepare

I create a component in the runtime directory : runtime/components/TestComponent.vue

Inside this component, the IDE doesn't know the vuejs functions : ref, watch, ...
TS2304: Cannot find name ref

When creating the component in the playground, the function are well recognized.

I encounter the problem in all IDE : IntelliJ, WebStorm, Visual Studio.
When launching the playground with the "npm run dev" command, all work fine event if the IDE display this error.

I have tried several settings in the IDE but non of them solve the problem.

Have you any idea ?

Regards,

Vue & Nuxt primitives are not available

Dear Nuxt team,

I noticed 2 issues with module starter template.

issue 1

Nuxt throws 500 error when you try to use a ref in the injected plugin. I believe that worked before.
See https://stackblitz.com/edit/github-5m1frr?file=src%2Fruntime%2Fplugin.ts

issue 2

Nuxt throws 500 error when you try to use a useNuxtApp in the playground/app.vue file. Explicit import helps, but I assume it should be auto-imported.
See https://stackblitz.com/edit/github-5m1frr?file=playground%2Fapp.vue

Run Npx nuxt/nuxi init Error. can't init the nuxt3 project.

run "npx nuxi init -t v3 nuxt-app" or "npx nuxt init" or "npx nuxi init" failed, any file be not created. Not network issue ,I try a lots of times(using/nouse proxy, change proxy node and use anthoer network environment)
show my commend and print
image

D:\123>npx nuxi init -t v3 nuxt-app
Nuxi 3.0.0

 ERROR  Failed to download template from registry: request to https://raw.githubusercontent.com/nuxt/starter/templates/templates/v3.json failed, reason: getaddrinfo ENOENT raw.githubusercontent.com                              10:47:24

  at /D:/dev/node/node_cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/chunks/init.mjs:15133:11
  at processTicksAndRejections (node:internal/process/task_queues:96:5)
  at async downloadTemplate (/D:/dev/node/node_cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/chunks/init.mjs:15132:20)
  at async Object.invoke (/D:/dev/node/node_cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/chunks/init.mjs:15200:15)
  at async _main (/D:/dev/node/node_cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/cli.mjs:50:20)

Update theme template

Following nuxt-themes/starter#13;

I think https://github.com/nuxt/starter/tree/theme should be used as the most minimal way to start a theme!

That way, https://github.com/nuxt-themes/starter could reflect the way we build themes at NuxtLabs (with lots of opinionated choices), and keep that official template as minimal as possible for anyone to build its own way of doing it?

I would happily open a PR about this here, but I would love to get @pi0 opinion on what structure should we give to most minimal theme here?

  • Is the .playground directory sufficient to you?
  • How do you think should we push people to publish their theme?
    • We currently use NPM with Docus, and GitHub template for Studio deployments
  • What is best setup for TS support inside .playground and root of project at the same time?

[WARNING] Nuxi project Markdown Bare Links Warning

Environment


  • Operating System: Windows_NT
  • Node Version: v18.15.0
  • Nuxt Version: 3.3.2
  • Nitro Version: 2.3.2
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

None

Describe the bug

I tried to find the source code of the nuxi project template, so I can make my first contribution, but couldn't find it. 😔

Markdown is throwing a warning about bare links on the README.md file of a project created with nuxi.

To silence it, I wrap the link in code block.

## Development Server

Start the development server on `http://localhost:3000`

Of course, I could make a rule for Markdown, but I think it's a good practice to always wrap the links in code block, for UX and DX, and not having to worry about this error in a freshly generated project.

Appreciation to the Nuxt team for all the hard and beautiful work being done. Great framework.

Additional context

No response

Logs

No response

Nuxt.new "Content" ("doc-driven") Stackblitz does not build

Going to https://nuxt.new/ and choosing the Content option (npx nuxi init -t doc-driven app) on Stackblitz does not start successfully and produces the following errors:

In terminal:

✔ Nitro built in 1000 ms                                                                                                                                         nitro 15:08:10
[Vue warn]: Unhandled error during execution of setup function 
  at <ErrorDev statusCode=500 statusMessage="Internal Server Error" description="head.addEntry is not a function"  ... >
[nuxt] [request error] [unhandled] [500] head.addEntry is not a function
  at eval (./node_modules/nuxt/dist/head/runtime/lib/vueuse-head.plugin.mjs:11:8)  
  at fn (./node_modules/nuxt/dist/app/nuxt.mjs:148:27)  
  at Object.callAsync (./node_modules/unctx/dist/index.mjs:68:19)  
  at callWithNuxt (./node_modules/nuxt/dist/app/nuxt.mjs:150:23)  
  at applyPlugin (./node_modules/nuxt/dist/app/nuxt.mjs:94:29)  
  at Module.applyPlugins (./node_modules/nuxt/dist/app/nuxt.mjs:104:11)  
  at async createNuxtAppServer (./node_modules/nuxt/dist/app/entry.mjs:30:7)  
  at async 𝐝𝐞𝐟𝐚𝐮𝐥𝐭 (./node_modules/@nuxt/vite-builder/dist/runtime/vite-node.mjs:42:18)  
  at async Object.renderToString (./node_modules/vue-bundle-renderer/dist/runtime.mjs:198:19)  
  at async eval (./.nuxt/dev/index.mjs:2686:21)
[Vue warn]: Unhandled error during execution of setup function 
  at <ErrorDev statusCode=500 statusMessage="" description="head.addEntry is not a function"  ... >
[Vue warn]: Unhandled error during execution of setup function 
  at <ErrorDev statusCode=500 statusMessage="Internal Server Error" description="head.addEntry is not a function"  ... >
[nuxt] [request error] [unhandled] [500] head.addEntry is not a function
  at eval (./node_modules/nuxt/dist/head/runtime/lib/vueuse-head.plugin.mjs:11:8)  
  at fn (./node_modules/nuxt/dist/app/nuxt.mjs:148:27)  
  at Object.callAsync (./node_modules/unctx/dist/index.mjs:68:19)  
  at callWithNuxt (./node_modules/nuxt/dist/app/nuxt.mjs:150:23)  
  at applyPlugin (./node_modules/nuxt/dist/app/nuxt.mjs:94:29)  
  at Module.applyPlugins (./node_modules/nuxt/dist/app/nuxt.mjs:104:11)  
  at async createNuxtAppServer (./node_modules/nuxt/dist/app/entry.mjs:30:7)  
  at async 𝐝𝐞𝐟𝐚𝐮𝐥𝐭 (./node_modules/@nuxt/vite-builder/dist/runtime/vite-node.mjs:42:18)  
  at async Object.renderToString (./node_modules/vue-bundle-renderer/dist/runtime.mjs:198:19)  
  at async eval (./.nuxt/dev/index.mjs:2686:21)
[Vue warn]: Unhandled error during execution of setup function 
  at <ErrorDev statusCode=500 statusMessage="" description="head.addEntry is not a function"  ... >

In website preview:

No response returned from render handler: /__nuxt_error?url=/&statusCode=500&statusMessage&message=head.addEntry+is+not+a+function&stack=%3Cpre%3E%3Cspan+class=%22stack+internal%22%3Eat+eval+(./node_modules/nuxt/dist/head/runtime/lib/vueuse-head.plugin.mjs:11:8)%3C/span%3E%0A%3Cspan+class=%22stack+internal%22%3Eat+fn+(./node_modules/nuxt/dist/app/nuxt.mjs:148:27)%3C/span%3E%0A%3Cspan+class=%22stack+internal%22%3Eat+Object.callAsync+(./node_modules/unctx/dist/index.mjs:68:19)%3C/span%3E%0A%3Cspan+class=%22stack+internal%22%3Eat+callWithNuxt+(./node_modules/nuxt/dist/app/nuxt.mjs:150:23)%3C/span%3E%0A%3Cspan+class=%22stack+internal%22%3Eat+applyPlugin+(./node_modules/nuxt/dist/app/nuxt.mjs:94:29)%3C/span%3E%0A%3Cspan+class=%22stack+internal%22%3Eat+Module.applyPlugins+(./node_modules/nuxt/dist/app/nuxt.mjs:104:11)%3C/span%3E%0A%3Cspan+class=%22stack+internal%22%3Eat+async+createNuxtAppServer+(./node_modules/nuxt/dist/app/entry.mjs:30:7)%3C/span%3E%0A%3Cspan+class=%22stack+internal%22%3Eat+async+%F0%9D%90%9D%F0%9D%90%9E%F0%9D%90%9F%F0%9D%90%9A%F0%9D%90%AE%F0%9D%90%A5%F0%9D%90%AD+(./node_modules/@nuxt/vite-builder/dist/runtime/vite-node.mjs:42:18)%3C/span%3E%0A%3Cspan+class=%22stack+internal%22%3Eat+async+Object.renderToString+(./node_modules/vue-bundle-renderer/dist/runtime.mjs:198:19)%3C/span%3E%0A%3Cspan+class=%22stack%22%3Eat+async+eval+(./.nuxt/dev/index.mjs:2686:21)%3C/span%3E%3C/pre%3E&data

[Module] Add GitHub Actions

Adding this as more of a discussion issue.

It would be great to see some sort of GitHub action template for testing on main push / PRs.

This could use ni (or UnJS equivalent) to continue allowing users to user whatever package manager they want.

Personally, I'd also like a release script but this is a bit more complicated due to having to manage NPM tokens.

Addition of ESLint and Prettier to starter template

Is there any chance that ESLint and prettier and even stylelint could be added to the starter? create-nuxt-app for Nuxt 2 had loads of options to bootstrap all the necessary tooling including tests, something that's missing in the starter templates. Would be great if they can be added.

Nuxt module starter is broken

Hello,

When creating a new Nuxt Module, there is an error with the vitest dependecy.

Here is the command and it's result :

$ npx nuxi init -t module my-module

✔ Which package manager would you like to use?
npm
◐ Installing dependencies...                                                                                                                                                                   14:11:34
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/vitest
npm ERR!   dev vitest@"^0.33.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional vitest@"^0.34.6 || ^1.0.0" from @nuxt/[email protected]
npm ERR! node_modules/@nuxt/test-utils
npm ERR!   dev @nuxt/test-utils@"^3.9.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /home/user/.npm/_logs/2024-01-06T13_11_35_295Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2024-01-06T13_11_35_295Z-debug-0.log

 ERROR  Error: Command failed with exit code 1: npm install           

error: yarn prepack

  1. yarn prepack

error:

error TS5083: Cannot read file '/Users/hom/home/NuxtUI/playground/.nuxt/tsconfig.json'.

src/module.ts(3,45): error TS2792: Cannot find module '@nuxt/kit'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?
src/module.ts(19,61): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.

Error: Failed to compile. Check the logs above.
    at error (file:///Users/hom/home/NuxtUI/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
    at throwPluginError (file:///Users/hom/home/NuxtUI/node_modules/rollup/dist/es/shared/rollup.js:21807:12)
    at Object.error (file:///Users/hom/home/NuxtUI/node_modules/rollup/dist/es/shared/rollup.js:22530:20)
    at Object.error (file:///Users/hom/home/NuxtUI/node_modules/rollup/dist/es/shared/rollup.js:21984:42)
    at Object.transform (file:///Users/hom/home/NuxtUI/node_modules/rollup-plugin-dts/dist/rollup-plugin-dts.mjs:1590:26)
    at file:///Users/hom/home/NuxtUI/node_modules/rollup/dist/es/shared/rollup.js:22739:37
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  id: '/Users/hom/home/NuxtUI/src/module.ts',
  hook: 'transform',
  code: 'PLUGIN_ERROR',
  plugin: 'dts',
  watchFiles: [ '/Users/hom/home/NuxtUI/src/module.ts' ]
}

Layer template TS Language Server

Hello,

When hovering above, for example, defineNuxtConfig in nuxt.config.ts starts loading of types. But it fails with this error message
image
I have installed fresh layer template with command npx nuxi init nuxt-layer-tsls --template layer
Problem is in tsconfig.json. It wants types from .playground but, npm script npm run dev generates types with command nuxi prepare to root, not .playground.

Invalid template name: module

When im trying to run npx nuxi init -t module <module> im getting an error with the following message:

Invalid template name: module

Is their something im missing?

Cannot find name 'defineNuxtConfig'.ts(2304)

I tried to install Nuxt 3 layers inside a monorepo with turborepo. and I somehow get error with typescript where it's seems to not able to figure out nuxt types, but everything is fine inside .playground folder.

cannot find name

cannot find name

how can i fix this?

Unable to create nuxt3

when i run the command "npx nuxi init nuxt-app", I got this error:
Nuxt CLI v3.0.0-rc.3

WARN could not fetch remote https://github.com/nuxt/starter
WARN Make sure you have installed git correctly

#47 I looked up this record in the question and did the following operations according to the reply inside

npx nuxi@latest init nuxt-app

or

npm install -g nuxi

It seems that the problem cannot be solved, and the same error is reported

My node version is LST v16.15.1
My git version is 2.36.1

auto-imports aren't enabled in module template

Environment

  • Operating System: Windows_NT
  • Node Version: v16.18.1
  • Nuxt Version: 3.2.0
  • Nitro Version: 2.2.1
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

I created new nuxt module with nuxi init

npx nuxi init -t module my-module

Describe the bug

I'm creating a nuxt module and I've run into an issue where I can't auto import composables in the playground , this a fresh install.

{
  "name": "nuxt3-auth-module",
  "version": "1.0.0",
  "description": "My new Nuxt module",
  "license": "MIT",
  "type": "module",
  "exports": {
    ".": {
      "types": "./dist/types.d.ts",
      "import": "./dist/module.mjs",
      "require": "./dist/module.cjs"
    }
  },
  "main": "./dist/module.cjs",
  "types": "./dist/types.d.ts",
  "files": [
    "dist"
  ],
  "scripts": {
    "prepack": "nuxt-module-build",
    "dev": "nuxi dev playground",
    "dev:build": "nuxi build playground",
    "dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
    "release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
    "lint": "eslint .",
    "test": "vitest run",
    "test:watch": "vitest watch"
  },
  "dependencies": {
    "@nuxt/kit": "^3.2.2"
  },
  "devDependencies": {
    "@nuxt/eslint-config": "^0.1.1",
    "@nuxt/module-builder": "^0.2.1",
    "@nuxt/schema": "^3.2.0",
    "@nuxt/test-utils": "^3.2.0",
    "@nuxtjs/eslint-config-typescript": "^12.0.0",
    "changelogen": "^0.4.1",
    "eslint": "^8.34.0",
    "eslint-config-prettier": "^8.6.0",
    "eslint-plugin-prettier": "^4.2.1",
    "nuxt": "^3.2.0",
    "prettier": "^2.8.4",
    "typescript": "^4.9.5",
    "vitest": "^0.28.4",
    "vue-tsc": "^1.0.24"
  }
}

 // src/modules.ts

  setup(_moduleOptions, nuxt) {
    const resolver = createResolver(import.meta.url);

    // add the plugin
    const runtimeDir = resolver.resolve('./runtime');   // var to path of runtime
    nuxt.options.build.transpile.push(runtimeDir);

    addPlugin(resolver.resolve(runtimeDir, 'plugin')); // add plugin to nuxt

    addImports({
      name: 'useAuth',
      as: 'useAuth',
      from: resolver.resolve('runtime/composables/useAuth'),
    });
  },
// src/runtme/composables/useAuth.ts

export const useAuth = () => {
  return {
    login: 'testing composable',
  };
};

I've also tried addImprtsDir and no luck either
and I also tried the nuxt.hook

nuxt.hook('imports:dirs', (dirs) => {
      dirs.push(resolver.resolve(runtimeDir + '/composables'));
    });

I get an error that useAuth is undefined and I have to import it from import { useAuth } from '#imports';

app.vue inside playground folder

<template>
  <div>Nuxt module playground!</div>
  <Auth />
</template>

<script setup lang="ts">
const { login } = useAuth();
console.log(login);
</script>

How can I get this to work?

Additional context

No response

Logs

No response

Nuxt 马上就要更新到 4 的版本了

今年是2024年了,过去的众多框架发生了变化,
node+vue 依旧是前端必学,
但是 Nuxt 马上就迎来了 4 的版本,
鸿蒙的ArkTS语言暂不支持写服务器,
使用 Nuxt 来开发服务器。
Nuxt+ArkTS+鸿蒙生态,
会是如何有趣。

template including more features of nuxt

Describe the feature

Now I see that for Nuxt3 there is a big change related to the state of the project after the init. Now the project is completely empty and I need to spend a lot of time adding needed features, googling templates of them, googling structure, coping, and pasting it many times. It makes the process of the init project on Nuxt really annoying and, honestly, I hate this change. I would prefer to press delete several times to remove redundant parts of code than doing all this job. If this will remain to be the default behavior maybe there is a way to initiate a project with the Nuxt application, not just one component and config? Maybe it could be implemented as a template of the project, maybe a console command to add features, idk what is the better way.

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

Add starter for a component library with Histoire as playground

I would like to create a shared components library to include as module in several Nuxt applications. It would be extremely helpful to have a starter template with a dummy component and Histoire as playground with a dummy story.

Currently, I am struggling with modifying the starter template to have Histoire (and Tailwind) and omit the playground directory.

Cannot start on CodeSandbox

I've encountered 2 issues while trying to start the CodeSandbox template (that is accessible here Get Started):

  • First is telemetry that gets prompted in a read-only terminal
  • Second is this error, which I've not seen before:
    • CleanShot 2022-10-25 at 00 41 57@2x

run `nuxi prepare` as postinstall step in starter templates

Environment

Nuxt project info: 20:08:15


  • Operating System: Windows_NT
  • Node Version: v18.1.0
  • Nuxt Version: 3.0.0-rc.8
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

No repo required.

Describe the bug

npx nuxi init should create the .nuxt directory with the tsconfig.json file.

Currently, every time I create a project to record a Nuxt 3 tutorial, I get this annoying error showing that .nuxt/tsconfig.json is not found, and in order to have that file and shut the error away is by running the npm run dev. And for the tutorials, is not logical to run the app if we haven't set up configurations and project structure first. The tsconfig.json file is supposed to be part of the project. It's like "now let's run the app, just so we can create this file that the command to create the project failed to create, shut this error up, then we stop the app, and now we can continue configuring it".

Thank you.

Additional context

No response

Logs

No response

Conflicting peer dependency

Hi. A module starter cannot be initiated due to dependencies mismatch.
Can be reproduced in your own StackBlitz sandbox here: https://nuxt.new/s/module.

npx nuxi@latest init -t module my-module
✔ Which package manager would you like to use?
npm

◐ Installing dependencies...
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @nuxt/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/vitest
npm ERR!   dev vitest@"^0.34.3" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional vitest@"^0.30.0 || ^0.31.0 || ^0.32.0 || ^0.33.0" from @nuxt/[email protected]
npm ERR! node_modules/@nuxt/test-utils
npm ERR!   dev @nuxt/test-utils@"^3.7.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/vitest
npm ERR!   peerOptional vitest@"^0.30.0 || ^0.31.0 || ^0.32.0 || ^0.33.0" from @nuxt/[email protected]
npm ERR!   node_modules/@nuxt/test-utils
npm ERR!     dev @nuxt/test-utils@"^3.7.1" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /home/USERNAME/.npm/_logs/2023-09-11T07_20_59_280Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/USERNAME/.npm/_logs/2023-09-11T07_20_59_280Z-debug-0.log

 ERROR  Error: Command failed with exit code 1: npm install

Expose starters meta

Fetching starters require a git operation. Similar to nuxt/modules, we can expose a json file from main branch to easily gather information about available starters and their meta-data. It can be used by both nuxi cli and external projects need to list nuxt starters.

starter.json [Schema: TODO]

@nuxt/[email protected] invalid: "latest"

Environment

Description

I use nuxt to create nuxt projects

image

Then, the error that occurred when running "npm ls"

image

But the 'yarn list' can run normally

image

This error will not affect the normal operation of the project

image

It seems that it only affects the 'npm list' instruction

image

Solution

I think there was an error with this' @ latest '

image

The npm list command will only return to normal after I specify the version

image image

Both Alpine and Docus themes create an empty dir

Try running the init command for alpine or docus themes

npx nuxi init -t themes/alpine

It generates an empty folder named "blog". The timestamp of the folder created is always May 10, 10 AM GMT.

Maybe the last PR #363 has something to do with it? content-wind is working as expected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.