Description
Explanation of NuxtHub deployment issue within a monorepo project
Repo: https://github.com/serhii-chernenko/nuxthub-issue/
Content
Architecture
I expect a monorepo for complex project where I expect different Nuxt 3 apps that extends shared Nuxt 3 layers within one repository to speed up development and make easier a codebase management.
A structure is already prepared within the current repository but there are some expectations:
# Different apps with different NuxtHub projects and different domains
src/apps/admin # e.g. admin.nuxt.dev
src/apps/storefront # e.g. storefront.nuxt.dev
# Shared layers that could be used within end-apps
src/layers/ui
src/layers/ecommerce
src/layers/auth
src/layers/blog
Prepare local environment
Project workspaces
In the root package.json
file I have workspaces setup:
{
"workspaces": [
"src/layers/*",
"src/apps/*"
],
"scripts": {
"dev": "npm run dev --workspace @demo/app",
"build": "npm run dev --workspace @demo/app"
}
}
In the UI layer's package.json
the package named @demo/ui
:
{
"name": "@demo/ui"
}
In the App package.json
the package fakely installed with a file reference:
{
"dependencies": {
"@demo/ui": "file:../../layers/ui"
}
}
The layer package is extended in layers
of nuxt.config.ts
of the app
application:
export default defineNuxtConfig({
extends: [
['@demo/ui', { install: true }]
]
})
Remove node_modules
from any nested directories
Before starting development I have to remove any nested node_modules
and package-json.lock
files:
rm -rf src/layers/ui/node_modules src/layers/ui/package-lock.json
rm -rf src/apps/app/node_modules src/apps/app/package-lock.json
Local development
When I want to start the application I go to the root directory where I have the package.json
with the dev
script:
{
"scripts": {
"dev": "npm run dev --workspace @demo/app",
}
}
and run the command
npm install
npm run dev
When the app is started, everything works perfectly:
Prepare deployment environment
When everything is prepared for development, I want to build my application via NuxtHub service.
NuxtHub
Currently I have one NuxtHub project especially for the demo issue explanation:
It's a reference to the domain: https://nuxthub-issue.nuxt.dev/.
GitHub Actions and secrets
Regarding the documentation, I have to have 2 ENV variables such as NUXT_HUB_PROJECT_KEY
and NUXT_HUB_PROJECT_DEPLOY_TOKEN
.
NUXT_HUB_PROJECT_KEY
is provided there: https://admin.hub.nuxt.com/serhii-chernenko/nuxthub-issue/settings/environment
And NUXT_HUB_PROJECT_DEPLOY_TOKEN
is available there:
Then I added both secrets to github actions config: https://github.com/serhii-chernenko/nuxthub-issue/settings/secrets/actions
Issues
However, I got a couple of issues here.
Initial deployment
Initial deployment was successfully finished somehow but as a result, I see just a "clear" Nuxt 3 application and it's not the same as I have locally:
https://nuxthub-issue.nuxt.dev/
GitHub actions build failed
When I set up everything correctly, I have deployment errors:
https://github.com/serhii-chernenko/nuxthub-issue/actions/runs/12338464409/job/34433433401
The following package was not found and will be installed: [email protected]
Please login to deploy your project or set the `NUXT_HUB_USER_TOKEN` environment variable.
Local deployment
So, if GitHub actions are not working, I tried to repeat it locally.
I prepared the .env
file in the root directory and in the app directory just to be sure that it has to work in any cases:
When I run the command from the root project directory
nuxthub deploy
I got the error:
@nuxthub/core is not installed, make sure to install it with npx nuxt module add hub
So, I tried to run it from the app dir:
I got the error:
nuxt is not installed, please make sure that you are inside a Nuxt project.
It's expected because I expect workspaces here not to run anything inside nested apps, I want to make it working from the root project directory.
I also tried to change the application directory, but it didn't help:
Expected help
I want a clear explanation and detailed instructions how to make my current setup working. Please, don't suggest me to move layers to different repositories to extend them as external modules. I want exactly the setup what I described.
But decision of choosing NuxtHub make me mad at this point, because I spent 1 day and I totally failed.