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: Loading unprepared module npm:<pkg@version> #18744

Closed
shinebayar-g opened this issue Apr 17, 2023 · 11 comments · Fixed by #24107
Closed

error: Loading unprepared module npm:<pkg@version> #18744

shinebayar-g opened this issue Apr 17, 2023 · 11 comments · Fixed by #24107
Labels
bug Something isn't working correctly node compat

Comments

@shinebayar-g
Copy link

shinebayar-g commented Apr 17, 2023

After v1.32.4 we no longer have to pass --reload flag to update npm dependencies. It's a great improvement. However there is a little bug on the first run.
For example, this script deno run --allow-env --allow-write --allow-read main.ts gives the following error on the first run.

error: Loading unprepared module: npm:cdk8s@2.7.55, imported from: file:///Users/home/myapp/main.ts
Error: command "deno run --allow-env --allow-write --allow-read main.ts " at /Users/home/myapp returned a non-zero exit code 1
    at ChildProcess.<anonymous> (/Users/home/.nvm/versions/node/v18.15.0/lib/node_modules/cdk8s-cli/lib/util.js:51:27)
    at Object.onceWrapper (node:events:628:26)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)

If I call the command again it works.

Deno version: 1.32.4

@dsherret
Copy link
Member

What are the contents of main.ts?

@dsherret dsherret added bug Something isn't working correctly needs info needs further information to be properly triaged node compat labels Apr 19, 2023
@shinebayar-g
Copy link
Author

shinebayar-g commented Apr 19, 2023

Removed boilerplate code.

import * as fs from 'node:fs';
import { App, YamlOutputType } from 'cdk8s';
import { generate } from './src/lib/generate.ts';

const rootApp = new App();

async function main() {
    await generate(rootApp);
    rootApp.synth();
}

await main();

generate.ts does some logic around filesystem using these packages.

import * as fs from 'node:fs';
import { App, Chart } from 'cdk8s';
import { z } from 'zod';
// @deno-types="npm:@types/uuid@9"
import { v5 as uuidv5 } from 'uuid';

@dsherret dsherret removed the needs info needs further information to be properly triaged label Apr 19, 2023
@dsherret
Copy link
Member

Thanks!

@shinebayar-g
Copy link
Author

Hmm I can no longer reproduce the issue. I thought I was able to reproduce the issue whenever I bump my dependencies.
I'm cleaning npm modules cache folder, removing deno.lock and bumping dependency in the imports map. But it just works..
If you don't have a strong suspicion feel free to close this.

@nakasyou
Copy link

nakasyou commented Jul 2, 2023

I got a similar error too.

npm: Happened when I dynamically imported a schema.

@bartlomieju
Copy link
Member

Can you folks still repeat the problem on latest Deno version?

@hannobraun
Copy link

I just got this error after upgrading a Lume website to the latest version. Full error:

TypeError: Loading unprepared module: npm:@tailwindcss/typography, imported from: file:///home/hanno/Projects/New/hannobraun.com/_config.ts
    at async createSite (https://deno.land/x/lume@v1.18.5/cli/run.ts:50:17)
    at async build (https://deno.land/x/lume@v1.18.5/cli/build.ts:33:16)
    at async Command.execute (https://deno.land/x/cliffy@v0.25.7/command/command.ts:1794:7)
    at async Command.parseCommand (https://deno.land/x/cliffy@v0.25.7/command/command.ts:1639:14)
    at async (https://deno.land/x/lume@v1.18.5/cli.ts:135:3)

The error disappeared when I tried again.

Deno version:

$ deno --version
deno 1.36.3 (release, x86_64-unknown-linux-gnu)
v8 11.6.189.12
typescript 5.1.6

So not quite the latest one.

@loynoir
Copy link

loynoir commented Oct 16, 2023

I encounter this after update deno and importmap.

After debug, actually, the problem is, error is throw at top level when import module A, but reported as loading unprepared module B.

In another word, inaccurate error report.

And the problem of A in my situation is a mix of three

After disable related test, it's fine again.

So, in short, related to #20919

@loynoir
Copy link

loynoir commented Oct 17, 2023

For mixed errors report, SuppressedError might be useful.

https://github.com/tc39/proposal-explicit-resource-management

@birkskyum
Copy link
Contributor

birkskyum commented Mar 17, 2024

@loynoir , it seems like #20914 was fixed - does it change your output?

@loynoir
Copy link

loynoir commented Mar 18, 2024

Yes and no.

Below command success very very very often.

$ deno test -A -c deno.json --parallel --no-check --coverage=xxx ./foo.test.ts

Still sometime fail with error Loading unprepared module: npm:X@Y under archlinux container with deno 1.41.1.

Guess there is race condition in deno code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants