m0ltz
m0ltz2mo ago

Haalp! Trying Windmill for the first time and failing!

A dev with 10+ years of Node/TS experience, but still can't figure it out! Did wmill sync push --yes Run from the UI:
error: Cannot find package 'windmill-client' from '/tmp/bun/main.ts'
Script is this:
//nobundling
import * as wmill from 'windmill-client';

export async function main() {
const { token } = await wmill.getResource('u/foo/bar')
console.log('ta', token)
return "Hello world";
}
//nobundling
import * as wmill from 'windmill-client';

export async function main() {
const { token } = await wmill.getResource('u/foo/bar')
console.log('ta', token)
return "Hello world";
}
Tried without nobundling, it also fails but in a different way.
23 Replies
m0ltz
m0ltzOP2mo ago
Oddly enough, if I go into edit mode, and press "Test" there, without any changes, it works. Works both ways with and without "nobundling". Ok, after I "deployed" from the UI, and then did a sync down. I see that it updated slack_list_channels.script.lock file. How is it supposed to be updated when developing on local?
fjørdlek
fjørdlek2mo ago
there is also a way to regenerate metadata: wmill script generate-metadata using the cli
m0ltz
m0ltzOP2mo ago
Yes, I followed that link
fjørdlek
fjørdlek2mo ago
that command should have locally generated the script.lock file
m0ltz
m0ltzOP2mo ago
Just ran:
wmill script generate-metadata
wmill script generate-metadata
And then pushed, and it actually broke a working version 😂
error: Could not resolve: "@slack/web-api". Maybe you need to "bun install"?
error: Could not resolve: "@slack/web-api". Maybe you need to "bun install"?
It's interesting, because when I again edit in the browser, and deploy and pull down, it creates a huge diff, where a bunch of deps get deleted and replaced. In the slack_list_channels.script.lock file
m0ltz
m0ltzOP2mo ago
That's just part of it
No description
m0ltz
m0ltzOP2mo ago
The green is what the web UI did, and the red is the generate-metadata version
fjørdlek
fjørdlek2mo ago
ok that is weird, let me try to reproduce can you send me the imports of the script? I guess from the green part its only slack and windmill client?
m0ltz
m0ltzOP2mo ago
import * as wmill from 'windmill-client';
import { WebClient } from '@slack/web-api';
import * as wmill from 'windmill-client';
import { WebClient } from '@slack/web-api';
fjørdlek
fjørdlek2mo ago
thanks!
m0ltz
m0ltzOP2mo ago
thanks to you! 🙂
fjørdlek
fjørdlek2mo ago
what cli version are you on
m0ltz
m0ltzOP2mo ago
Version: 1.508.0 I just setup everything today, and opened an account today, so should be on latest everything, in theory ❯ bun --version 1.2.18
fjørdlek
fjørdlek2mo ago
ok, yeah sorry about that rough start I'll investigate and get back to you about this ok strange: I tried the following in a clean new folder:
wmill script bootstrap f/test/hello2 bun
wmill script bootstrap f/test/hello2 bun
then edit f/test/hello2.ts
import * as slack from "@slack/web-api";
import * as wmill from 'windmill-client';

export async function main() {
const { token } = await wmill.getResource('u/alex/test1234')
console.log(slack);
console.log('ta', token)
return "Hello world";
}
import * as slack from "@slack/web-api";
import * as wmill from 'windmill-client';

export async function main() {
const { token } = await wmill.getResource('u/alex/test1234')
console.log(slack);
console.log('ta', token)
return "Hello world";
}
then
wmill script generate-metadata
wmill script generate-metadata
which results in this
cat f/test/hello2.script.lock
{
"dependencies": {
"@slack/web-api": "latest",
"windmill-client": "latest"
}
}
//bun.lock
{
"lockfileVersion": 1,
"workspaces": {
"": {
"dependencies": {
"@slack/web-api": "latest",
"windmill-client": "latest",
},
},
},
"packages": {
...
cat f/test/hello2.script.lock
{
"dependencies": {
"@slack/web-api": "latest",
"windmill-client": "latest"
}
}
//bun.lock
{
"lockfileVersion": 1,
"workspaces": {
"": {
"dependencies": {
"@slack/web-api": "latest",
"windmill-client": "latest",
},
},
},
"packages": {
...
so far I think we're aligned then you pushed it and it added bunch of stuff to your lockfile right? did you maybe at one point import the windmill-cli in your script ? anyway, would be good if you could try reproduce those steps above with my dummy script just to be sure not something else is going on
m0ltz
m0ltzOP2mo ago
then you pushed it and it added bunch of stuff to your lockfile right?
I pushed it Then deployed it Then sync'ed back down >did you maybe at one point import the windmill-cli in your script ? no, but i think i did install it into the project package.json
m0ltz
m0ltzOP2mo ago
So, following your steps, after I generate the meta data, the lock file is like this:
m0ltz
m0ltzOP2mo ago
Any ideas?
fjørdlek
fjørdlek2mo ago
So yeah, looks like you have locally installed the cli which explains why when you click deploy in the UI (this will trigger the building of the lock file) it will generate a conflicting lock file. But your script should still run. Are you still getting errors?
m0ltz
m0ltzOP2mo ago
Ok but if I don’t install the CLI how am I supposed to use it?
fjørdlek
fjørdlek2mo ago
it's ok to install globally (npm i -g) but it seems it ended up in your local scripts lock file? if you create a fully new script from scratch (new clean folder that you're syncing with the cli) you shouldn't get the cli dependency in your local lock file
m0ltz
m0ltzOP2mo ago
I don't like installing globally, I think it's an anti-pattern, and it's also not stable, as I have many Node.js versions on my computer (managed by nvm) so you never know where it's going to be installed. Is there no way to install the CLI in the project? And I am still not understanding how this CLI affects the remote scripts. How does it conflict? Shouldn't the script only use locks that are part of the script? Why does it even pay attention to the root lock file?
rubenf
rubenf2mo ago
Hi, you have no reason to have multiple versions of the windmill-cli installed, it's just a binary in this case so you should install it globally or use it with npx the CLI has many advanced features, one of them is to make the package.json affect the lockfile generation of all scripts in the same folder hierarchy if you do not want that feature, do not have any package.json in that folder

Did you find this page helpful?