You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building a NPM module with deno, it will error out and fail to find the local module.
deno run -A build_npm.ts 0.0.1"
Error
[dnt] Building project...
[dnt] Type checking ESM...
src/main.ts:6:17 - error TS2339: Property 'main' does not exist on type'ImportMeta'.
6 if (import.meta.main) {
~~~~
src/main_test.ts:2:30 - error TS2307: Cannot find module '@std/assert' or its corresponding type declarations.
2 import { assertEquals } from "@std/assert";~~~~~~~~~~~~~
error: Uncaught (in promise) Error: Had 2 diagnostics.
throw new Error(`Had ${diagnostics.length} diagnostics.`);
^
at getProgramAndMaybeTypeCheck (https://deno.land/x/[email protected]/mod.ts:450:17)
at build (https://deno.land/x/[email protected]/mod.ts:343:17)
at eventLoopTick (ext:core/01_core.js:177:7)
at async file:///tmp/npm/myadd/build_npm.ts:5:1
deno.json
{
"tasks": {
"dev": "deno run --watch main.ts",
"npm": "deno run -A build_npm.ts 0.0.1"
},
"imports": {
"@std/assert": "jsr:@std/assert@1"
}
}
exportfunctionmyAdd(a: number,b: number): number{returna+b;}// Learn more at https://docs.deno.com/runtime/manual/examples/module_metadata#conceptsif(import.meta.main){console.log("Add 2 + 3 =",myAdd(2,3));}
build_npm.ts
import{build,emptyDir}from"https://deno.land/x/[email protected]/mod.ts";awaitemptyDir("./npm");awaitbuild({entryPoints: ["./main.ts"],outDir: "./npm",shims: {deno: true,},package: {name: "myapp",version: Deno.args[0],description:
"Boolean function that returns whether or not parameter is the number 42",license: "MIT",repository: {type: "git",url: "git+https://github.com/lambtron/is-42.git",},bugs: {url: "https://github.com/lambtron/is-42/issues",},},postBuild(){Deno.copyFileSync("README.md","npm/README.md");},});
The text was updated successfully, but these errors were encountered:
Version: Deno 2.1.9
When building a NPM module with deno, it will error out and fail to find the local module.
deno run -A build_npm.ts 0.0.1"
Error
deno.json
main_test.ts
main.ts
build_npm.ts
The text was updated successfully, but these errors were encountered: