create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Module not found: Can't resolve in src when installing module from local folder

Open wizzfizz94 opened this issue 8 years ago • 3 comments

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes I've tried re-creating the project with both npm and yarn after updated the package managers. npm version: 6.2.0 yarn version: 1.9.4

Which terms did you search for in User Guide?

Search words: Module not found: Can't resolve local install src

Environment

Environment: OS: Linux 4.8 Node: 10.9.0 Yarn: 1.9.4 npm: 6.2.0 Watchman: Not Found Xcode: N/A Android Studio: Not Found

Packages: (wanted => installed) react: ^16.4.2 => 16.4.2 react-dom: ^16.4.2 => 16.4.2 react-scripts: 1.1.4 => 1.1.4

Steps to Reproduce

  1. cd src/
  2. git clone https://github.com/alexsyo/react-circular-slider-bar
  3. cd ..
  4. yarn add file:src/react-circular-slider-bar
  5. added the circular component as instructed by https://github.com/alexsyo/react-circular-slider-bar to App.js
  6. yarn start

Expected Behavior

Module should be found in src file and loaded with webpack but it cannot be found. I noticed that the module itself has a dependacy on an old version of webpack but im not sure if this would effect behaviour. It should also be noted that this error has been fluctuating ie. sometimes occurs and sometimes doesnt. Does this have something to do with the linking of local files with webpack?

this is the folder structure: ├── package.json ├── public │   ├── favicon.ico │   ├── index.html │   └── manifest.json ├── README.md ├── src │   ├── App.css │   ├── App.js │   ├── App.test.js │   ├── index.css │   ├── index.js │   ├── logo.svg │   ├── react-circular-slider-bar

Actual Behavior

compiler errors: selection_079 selection_078

Reproducible Demo

No demo at this stage.

wizzfizz94 avatar Aug 21 '18 01:08 wizzfizz94

@wizzfizz94 Why would you want to clone react-circular-slider-bar within your project?

You can just npm/yarn install it from your project root (not /src) and then import it as usual as per the instructions on react-circular-slider-bar

kartiklad avatar Aug 23 '18 00:08 kartiklad

@kartiklad I also tried cloning the repo to the project root but experienced the same issue. I was cloning to src as i was making modifications to the module for my project. Is that not standard practise?

wizzfizz94 avatar Aug 26 '18 00:08 wizzfizz94

Usually there is a build step involved in transpiling source code, for example: https://github.com/alexsyo/react-circular-slider-bar/blob/master/package.json#L9

I would suggest you to clone it somewhere else, make modifications, do npm pack and then use the tgz file in package.json. https://docs.npmjs.com/files/package.json#local-paths

If you use local path it would work as well, but you should run the build command from that repo and reference the build directory.

bugzpodder avatar Aug 30 '18 07:08 bugzpodder