Skip to content

New project with typescript template causes Haste module naming collision error #26427

Closed
@stefanedberg

Description

@stefanedberg

When creating a new React Native project with typescript template the following error occurs:

┌──────────────────────────────────────────────────────────────────────────────┐
│                                                                              │
│  Running Metro Bundler on port 8081.                                         │
│                                                                              │
│  Keep Metro running while developing on any JS projects. Feel free to        │
│  close this tab and run your own Metro instance if you prefer.               │
│                                                                              │
│  https://github.com/facebook/react-native                                    │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘

Looking for JS files in
   /Users/user/development/ProjectName 

Loading dependency graph...jest-haste-map: Haste module naming collision: ProjectName
  The following files share their name; please adjust your hasteImpl:
    * <rootDir>/package.json
    * <rootDir>/template/package.json

Failed to construct transformer:  { Error: Duplicated files or mocks. Please check the console for more info
    at setModule (/Users/user/development/ProjectName/node_modules/jest-haste-map/build/index.js:620:17)
    at workerReply (/Users/user/development/ProjectName/node_modules/jest-haste-map/build/index.js:691:9)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  mockPath1: 'package.json',
  mockPath2: 'template/package.json' }
(node:4451) UnhandledPromiseRejectionWarning: Error: Duplicated files or mocks. Please check the console for more info
    at setModule (/Users/user/development/ProjectName/node_modules/jest-haste-map/build/index.js:620:17)
    at workerReply (/Users/user/development/ProjectName/node_modules/jest-haste-map/build/index.js:691:9)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:4451) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4451) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Error: Duplicated files or mocks. Please check the console for more info
    at setModule (/Users/user/development/ProjectName/node_modules/jest-haste-map/build/index.js:620:17)
    at workerReply (/Users/user/development/ProjectName/node_modules/jest-haste-map/build/index.js:691:9)
    at process._tickCallback (internal/process/next_tick.js:68:7)

React Native version:

    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 530.60 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.16.3 - /usr/local/bin/node
    Yarn: 1.5.1 - /usr/local/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
    Android SDK:
      API Levels: 22, 23, 25, 26, 27, 28
      Build Tools: 23.0.1, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.2, 27.0.3, 28.0.3
      System Images: android-22 | Intel x86 Atom, android-22 | Intel x86 Atom_64, android-22 | Google APIs Intel x86 Atom_64, android-23 | Intel x86 Atom, android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-26 | Android TV Intel x86 Atom, android-26 | Android Wear Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-26 | Google Play Intel x86 Atom
      Android NDK: 16.1.4479499
  IDEs:
    Android Studio: 3.1 AI-173.4697961
    Xcode: 10.3/10G8 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.5 => 0.60.5
  npmGlobalPackages:
    create-react-native-app: 1.0.0
    react-native-app-id: 0.0.4
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7

Steps To Reproduce

  1. react-native init ProjectName --template typescript
  2. cd ProjectName && react-native run-ios

Describe what you expected to happen:
The development server should start and the app would run successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugStaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions