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

Crashes with "Cannot find module" #448

Closed
4 tasks done
Sti2nd opened this issue Aug 7, 2024 · 2 comments
Closed
4 tasks done

Crashes with "Cannot find module" #448

Sti2nd opened this issue Aug 7, 2024 · 2 comments

Comments

@Sti2nd
Copy link

Sti2nd commented Aug 7, 2024

Describe the bug

See the below Output and Reproduction.

Perhaps something weird; I have specified vitest version 2.0.5 in package.json and running with CLI works. Still the extension prints out vitest version 1.5.1.

Reproduction

Closed source code, but here are the relevant files (slightly modified)

// The file called findEnv.test.ts
/* eslint-disable no-template-curly-in-string */
import { env } from 'process';
import { findEnv } from './findEnv.js';

const CLIENTID = 'prefix/app/${APP_VERSION}';

describe('config', () => {
  it('should find env', () => {
    env.APP_VERSION = '1.0.0';

    const result = findEnv(CLIENTID);
    expect(result).toBe('prefix/app/1.0.0');
  });

  it('should throw error', () => {
    delete env.APP_VERSION;

    expect(() => findEnv(CLIENTID)).toThrowError(
      /Could not find env APP_VERSION/,
    );
  });
});
// The file called findEnv.ts
import { env } from 'process';

export function findEnv(str: string, strict: boolean = true): string {
  // Simplified code
  if (str === 'prefix/app/1.0.0') {
    return str
  } else {
    throw new Error(`Could not find env APP_VERSION`);
  }
}

Output

[INFO 2:17:42 PM] [v1.0.7] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 2:17:43 PM] [API] Running Vitest v1.5.1 (my-frontend-app/vite.config.ts) with Node.js: /home/my-username/.nvm/versions/node/v20.14.0/bin/node
[INFO 2:17:43 PM] [API] Vitest v1.5.1 (my-frontend-app/vite.config.ts) process 1466673 created
[INFO 2:18:00 PM] [API] Collecting tests: src/api/utils/findEnv.test.ts
[Worker] 
node:internal/event_target:1099
  process.nextTick(() => { throw err; });
                           ^
Error: Cannot find module '/home/my-username/repos/my-frontend-app/node_modules/tinypool/dist/esm/entry/worker.js'
    at Function._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Function._load (node:internal/modules/cjs/loader:986:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at MessagePort.<anonymous> (node:internal/main/worker_thread:186:26)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:825:20)
    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
Emitted 'error' event on Tinypool instance at:
    at EventEmitterReferencingAsyncResource.runInAsyncScope (node:async_hooks:206:9)
    at Tinypool.emit (file:///home/my-username/repos/my-frontend-app/node_modules/tinypool/dist/esm/index.js:61:31)
    at Worker.<anonymous> (file:///home/my-username/repos/my-frontend-app/node_modules/tinypool/dist/esm/index.js:752:30)
    at Worker.emit (node:events:519:28)
    at [kOnErrorMessage] (node:internal/worker:326:10)
    at [kOnMessage] (node:internal/worker:337:37)
    at MessagePort.<anonymous> (node:internal/worker:232:57)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:825:20)
    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28) {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.14.0

Version

1.0.7

Validations

Copy link

github-actions bot commented Oct 7, 2024

Hello @Sti2nd. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@Sti2nd
Copy link
Author

Sti2nd commented Oct 7, 2024

Ok then, no help from me.

@Sti2nd Sti2nd closed this as completed Oct 7, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants