metro icon indicating copy to clipboard operation
metro copied to clipboard

Haste could not resolve module with dot folder in the path (.build)

Open tuanmai opened this issue 8 years ago • 2 comments

Do you want to request a feature or report a bug? It's a bug

What is the current behavior? I added a package with the path to the main file is .build/index.js. I can run the project on local successfully, but when I try to build. It shows this error.

While trying to resolve module `redux-api-call-adapter-dedupe` from file `/Users/tuanmai/code/MetroExample/index.js`, the package `/Users/tuanmai/code/MetroExample/node_modules/redux-api-call-adapter-dedupe/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/tuanmai/code/MetroExample/node_modules/redux-api-call-adapter-dedupe/.build/index.js`. Indeed, none of these files exist:

  * `/Users/tuanmai/code/MetroExample/node_modules/redux-api-call-adapter-dedupe/.build/index.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
  * `/Users/tuanmai/code/MetroExample/node_modules/redux-api-call-adapter-dedupe/.build/index.js/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`

I tried to change the path on package.json and the folder name to build/index.js and it works normally.

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test. Repo: https://github.com/tuanmai/metro-error-example (just created by react-native init then add the lib with /.build/index.js path. Steps:

  • yarn install
  • node node_modules/react-native/local-cli/cli.js bundle --platform android --reset-cache --entry-file index.js --bundle-output bundle.js --assets-dest .

What is the expected behavior? It should work with the .build/index.js Old metro version (0.30.2) with react native 0.55 works.

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system. Current metro version: 0.48.3 node: v8.9.0 yarn: 1.10.1 OS: MacOS 10.14.1

tuanmai avatar Dec 05 '18 03:12 tuanmai

I experienced this too. It's annoying that I have to clone the dependencies and change build path.

toan2406 avatar Jul 08 '19 14:07 toan2406

We're triaging older issues. Metro's file map now includes files inside dot-directories by default, so package entry points such as .build/index.js are supported. This is resolved.

robhogan avatar Aug 29 '26 19:08 robhogan