Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error building app when including file asset from nestjs root folder in nest-cli.json #2677

Closed
2 of 4 tasks
jaunusa opened this issue Aug 2, 2024 · 3 comments
Closed
2 of 4 tasks

Comments

@jaunusa
Copy link

jaunusa commented Aug 2, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

The nestjs build fails when addeing a single file asset item to copy a config file from the nestjs root directory.

nest-cli throws: cant go up that far

tsconfig.json customization:

...
"outDir": "../../dist/server",
"rootDir": "./"

assets configuration in nest-cli.json:

{
  "$schema": "https://json.schemastore.org/nest-cli",
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
    "deleteOutDir": true,
    "assets": [
        {
            "include": "../.config.yaml",
            "watchAssets": true
        },
        {
            "include": "../assets",
            "watchAssets": true,
            "outDir": "../../dist/server/assets"
        }
    ]
  }
}

Minimum reproduction code

https://github.com/jaunusa/nestjs-file-asset-issue

Steps to reproduce

  1. cd apps/server
  2. npm install
  3. nest build
  4. see error: cant go up that far

Expected behavior

I would expect that building the app copies .config.yaml to build output directory like it does with the assets folder. When I remove the assets entry for .config.yaml the assets folder is copied whithout throwing any error.

Package version

10.4.2

NestJS version

10.3.10

Node.js version

18.18.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

The reproduction projects structure with custom output paths, is a simplified example for using nestjs in a monorepo setup.

@kamilmysliwiec
Copy link
Member

Would you like to create a PR that changes this line

if (depth(inPath) < up) {
throw new Error('cant go up that far');

to up - 1 (in the if condition)? We could also improve the error message to make it a bit more self descriptive

@jaunusa
Copy link
Author

jaunusa commented Aug 5, 2024

PR created: #2681

@kamilmysliwiec
Copy link
Member

Let's track this here #2681

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants