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: EISDIR: illegal operation on a directory, read (npm test) #1009

Open
2 tasks
aelbore opened this issue Apr 5, 2024 · 8 comments
Open
2 tasks

Error: EISDIR: illegal operation on a directory, read (npm test) #1009

aelbore opened this issue Apr 5, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@aelbore
Copy link

aelbore commented Apr 5, 2024

Please provide the environment you discovered this bug in.

stackblitz
https://stackblitz.com/edit/stackblitz-starters-yjhfgh

Just download and run it locally

Which area/package is the issue in?

vite-plugin-angular

Description

when running the test it has "Error: EISDIR: illegal operation on a directory" error.
when using "happy-dom" and "jsdom" with "[email protected]"

it works fine if

  • when it using playwright it works fine with
  • using "happy-dom" and "jsdom" with "[email protected]"

Note: not too sure if this is analogjs issue or with vite/vitest

Please provide the exception or error you saw

"Error: EISDIR: illegal operation on a directory"

Other information

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@aelbore aelbore added the bug Something isn't working label Apr 5, 2024
@brandonroberts
Copy link
Member

I've run into a similar issue also in another repo. Did some digging here and it has something to do with the bundling of rxjs. If you disable the angular plugin, you get.

 FAIL  src/app.component.spec.ts [ src/app.component.spec.ts ]
Error: Directory import '/Users/dev/projects/stackblitz-starters-yjhfgh/node_modules/rxjs/operators' is not supported resolving ES modules imported from /Users/dev/projects/stackblitz-starters-yjhfgh/node_modules/@angular/core/fesm2022/testing.mjs
Did you mean to import rxjs/operators/index.js?
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { url: 'file:///Users/dev/projects/stackblitz-starters-yjhfgh/node_modules/rxjs/operators', code: 'ERR_UNSUPPORTED_DIR_IMPORT' }

If you go into the .mjs files and replace rxjs/operators with rxjs/operators/index.js, it works fine.

@aelbore
Copy link
Author

aelbore commented Apr 5, 2024

@brandonroberts thanks will try this, by the way thanks for the plugin great job ^_^

@brandonroberts
Copy link
Member

brandonroberts commented Apr 5, 2024

Found a workaround.

/// <reference types="vitest" />
import { defineConfig } from 'vite';

import angular from '@analogjs/vite-plugin-angular';

export default defineConfig(({ mode }) => ({
  plugins: [angular()],
  test: {
    globals: true,
    setupFiles: ['src/test-setup.ts'],
    environment: 'happy-dom',
    include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
    reporters: ['default'],
    server: {
      deps: {
        inline: [/fesm2022/]
      }
    }
  },
  define: {
    'import.meta.vitest': mode !== 'production',
  },
}));

We're already doing this internally but only for cdk/fesm libraries because it slows down running the tests.

@aelbore
Copy link
Author

aelbore commented Apr 5, 2024

Found a workaround.

/// <reference types="vitest" />
import { defineConfig } from 'vite';

import angular from '@analogjs/vite-plugin-angular';

export default defineConfig(({ mode }) => ({
  plugins: [angular()],
  test: {
    globals: true,
    setupFiles: ['src/test-setup.ts'],
    environment: 'happy-dom',
    include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
    reporters: ['default'],
    server: {
      deps: {
        inline: [/fesm2022/]
      }
    }
  },
  define: {
    'import.meta.vitest': mode !== 'production',
  },
}));

We're already doing this internally but only for cdk/fesm libraries because it slows down running the tests.

@brandonroberts wow this works for me, is this just a work around if using [email protected]?
thank you so much on this, i didnt know theres server options in test

@brandonroberts
Copy link
Member

@aelbore not sure if its only needed for rxjs 6.x because our tests are running fine without it on RxJS 7.x. Maybe it surfaced as a result of switching to ESM.

I may add it as a config option because of the performance cost, but I'd prefer to not include it by default.

@ahnpnl
Copy link

ahnpnl commented May 29, 2024

I ran into this error as well with RxJs 7.x. The workaround works for me.

@brandonroberts
Copy link
Member

I ran into this error as well with RxJs 7.x. The workaround works for me.

What version of RxJS was it?

@ahnpnl
Copy link

ahnpnl commented May 30, 2024

It is 7.8.1, this is the repo https://github.com/ahnpnl/monorepo-multi-apps

To reproduce:

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

No branches or pull requests

3 participants