previewjs icon indicating copy to clipboard operation
previewjs copied to clipboard

Conflicting issue when npm library same as folder path

Open DavidLozzi opened this issue 4 years ago • 1 comments

Describe the bug

We are using redux, importing like

import { bindActionCreators } from 'redux';

but we also have a folder called redux:

import history from 'redux/history';

the app is erroring with

 > node_modules/redux-devtools-extension/index.js:3:22: error: Cannot read file "src/redux": is a directory
    3 │ var compose = require('redux').compose;
      ╵                       ~~~~~~~

any way around this? other than renaming my folder?

Reproduction

see notes above

React Preview version

0.7.1

System Info

System:
    OS: macOS 11.6
    CPU: (8) x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
    Memory: 31.73 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.22.1 - ~/.nvs/node/10.22.1/x64/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.6 - ~/.nvs/node/10.22.1/x64/bin/npm
  IDEs:
    IntelliJ: 2021.1.1
    Nano: 2.0.6 - /usr/bin/nano
    VSCode: 1.61.2 - /usr/local/bin/code
    Vim: 8.2 - /usr/bin/vim
    Xcode: /undefined - /usr/bin/xcodebuild
  Browsers:
    Chrome: 95.0.4638.54
    Firefox: 88.0.1
    Safari: 15.0

Used Package Manager

npm

Extension logs (useful for crashes)

No response

Preview logs (useful for rendering errors)

No response

Anything else?

No response

DavidLozzi avatar Oct 22 '21 19:10 DavidLozzi

Hey @DavidLozzi, that's definitely an edge case I haven't thought about before. I suspect it would also be an issue when using ViteJS, which React Preview is based on. You might want to test that out.

I'd personally recommend using a prefix like "src/" for your local imports as your current usage can create confusion for humans too, but I do realise it's not that simple to update an entire codebase and I'm sure there are other considerations in your specific case.

I'll let you know if I think of a better way!

fwouts avatar Oct 22 '21 23:10 fwouts