#Build error with Quasar app

1 messages · Page 1 of 1 (latest)

weak crater
#

Hi,

I'm getting the following error message when trying to run the basic Dagger demo within a Quasar app:

dagger run node --loader ts-node/esm ./build.mts                                                                                       12:17:32
┣─╮ 
│ ▽ init
│ █ [1.06s] connect
│ ┣ [0.84s] starting engine
│ ┣ [0.22s] starting session
│ ┃ OK!                                                                                                                                                                                      
│ ┻ 
█ [0.25s] ERROR node --loader ts-node/esm ./build.mts
┃ (node:97028) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time                                                                               
┃ (Use `node --trace-warnings ...` to show where the warning was created)                                                                                                                    
┃ /home/richard/projects/sbs/ui/BudgetsUI/node_modules/ts-node/src/index.ts:859                                                                                                              
┃     return new TSError(diagnosticText, diagnosticCodes, diagnostics);

Any ideas?

lament aspen
#

Much simpler to use tsx rather than ts-node. Don't even need a tsconfig.

#

\cc @alpine tide

alpine tide
#

I usually execute my node program using the same command and it works, but I think it's more an issue with the code itself and typescript isn't showing it, sometime I hit that and once I fix the code it works well

#

Could you share some code?

weak crater
#

Sure, this is from the build.mts file:

import { connect, Client } from "@dagger.io/dagger"

// initialize Dagger client
connect(
  async (client: Client) => {
    // get Node image
    // get Node version
    const node = client.container().from("node:16").withExec(["node", "-v"])

    // execute
    const version = await node.stdout()

    // print output
    console.log("Hello from Dagger and Node " + version)
  },
  { LogOutput: process.stderr }
)
weak crater
alpine tide
#

Oh you just forget to call await on connect, here's an example of fix

import { connect, Client } from '@dagger.io/dagger'

async function main() {
// initialize Dagger client
    await connect(
        async (client: Client) => {
            // get Node image
            // get Node version
            const node = client.container().from("node:16").withExec(["node", "-v"])

            // execute
            const version = await node.stdout()

            // print output
            console.log("Hello from Dagger and Node " + version)
        },
        { LogOutput: process.stderr }
    )
}

main()

Result:

Hello from Dagger and Node v16.20.2
#

The error hasn't been reported tho, that's strange

weak crater
#

Still getting hte same error?

#
import { connect, Client } from "@dagger.io/dagger"

async function main() {
    
// initialize Dagger client
await connect(
  async (client: Client) => {
    // get Node image
    // get Node version
    const node = client.container().from("node:16").withExec(["node", "-v"])

    // execute
    const version = await node.stdout()

    // print output
    console.log("Hello from Dagger and Node " + version)
  },
  { LogOutput: process.stderr }
)
}
#
ERROR node --loader ts-node/esm ./build.mts
┃ (node:100382) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time                                                                              
┃ (Use `node --trace-warnings ...` to show where the warning was created)                                                                                                                    
┃ /home/richard/projects/sbs/ui/BudgetsUI/node_modules/ts-node/src/index.ts:859                                                                                                              
┃     return new TSError(diagnosticText, diagnosticCodes, diagnostics);                                                                                                                      
┃            ^                                                                                                                                                                               
┃ TSError: ⨯ Unable to compile TypeScript:                                                                                                                                                   
┃ error TS6053: File '@quasar/app-vite/tsconfig-preset' not found.        
weak crater
lament aspen
#

If you have tsx in your $PATH:

dagger run tsx ./build.mts
weak crater
lament aspen
#

You need to call main(), but actually don't need to wrap connect in function main so you can remove that.

weak crater
lament aspen
#

Yes, exactly.

weak crater
#

Thank you for your help 🙂

#

I recommend that the Dagger docs get updated with the tsx command

lament aspen
#

Yeah, me too... at one point I meant to write an issue for it but somehow dropped it. \cc @solar smelt

solar smelt
lament aspen
#

It simplifies instructions. You no longer need a tsconfig.json as well.

#

So this step is not needed: npx tsc --init --module esnext --moduleResolution nodenext.

#

To be clear, tsx is for running typescript. So .ts or .mts.

#

Instead of npm install ts-node typescript I think you just need npm install tsx.

weak crater
#

Yes, from my point of view, I got stuck right at the beggining of what I thought would be an easy tutorial to follow, so anything that can make it simpler would be great 🙂

weak crater
solar smelt
#

Feel free to add more info in the issue.

weak crater
safe spruce