Birk SkyumB
Deno16mo ago
6 replies
Birk Skyum

canary `deno install` - can't find npm modules

deno 2.0.0-rc.1+7bfcb4d

I'm having a deno.json like this

{
  "tasks": {
    "test": "vitest"
  },
  "imports": {
    "vitest": "npm:vitest@^2.0.5"
  }
}


I run deno install

I have a test like this:

import { expect, test } from "vitest"; // <- "Cannot find module 'vitest' or its corresponding type declarations.ts(2307)
function sum(a, b) {
  return a + b
}
test('adds 1 + 2 to equal 3', () => {
  expect(sum(1, 2)).toBe(3)
})


Why can the type declarations not be found? deno install doesn't seem to make a node_modules folder by default - is that necessary for this this type to be found, or can the import mapping work?

I also have the vitest.config.ts like this:

import {defineConfig} from "vitest/config";

export default defineConfig({
  test: {
    include: ['sum.test.ts']
  }
})


and when I run the task deno task test I get an error that "vitest/config" also can't be found:

➜ deno task test
Task test vitest
✘ [ERROR] Unterminated string literal

    vitest.config.ts:1:366:
      1 │ ...e:///Users/admin/repos/deno-kitchensink/vitest-demo/vitest.config.ts";import {defineConfig} from "vitest/config';
        ╵                                                                                                                     ^

failed to load config from /Users/admin/repos/deno-kitchensink/vitest-demo/vitest.config.ts
Was this page helpful?