question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[v6 rc] Not able to use new rc - Error: this package itself specifies a `main` module field that could not be resolved

See original GitHub issue

When trying out the newest release from npm I encounter this error. this package itself specifies a 'main' module field that could not be resolved

stack trace

Error: While trying to resolve module `react-native-fbads` from file `/Users/myuser/projects/myapp/app/modules/ads/components/FBNativeAd.js`, the package `/Users/myuser/projects/myapp/node_modules/react-native-fbads/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/myuser/projects/myapp/node_modules/react-native-fbads/dist/lib/index.js`. Indeed, none of these files exist:

  * `/Users/myuser/projects/myapp/node_modules/react-native-fbads/dist/lib/index.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
  * `/Users/myuser/projects/myapp/node_modules/react-native-fbads/dist/lib/index.js/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
    at ResolutionRequest.resolveDependency (/Users/myuser/projects/myapp/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:61:15)
    at DependencyGraph.resolveDependency (/Users/myuser/projects/myapp/node_modules/metro/src/node-haste/DependencyGraph.js:218:16)
    at Object.resolve (/Users/myuser/projects/myapp/node_modules/metro/src/lib/transformHelpers.js:141:30)
    at dependencies.map.result (/Users/myuser/projects/myapp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:373:31)
    at Array.map (<anonymous>)
    at resolveDependencies (/Users/myuser/projectsmyapp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:369:18)
    at /Users/myuser/projects/myapp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:188:33
    at Generator.next (<anonymous>)
    at step (/Users/myuser/projects/myapp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:298:30)
    at /Users/myuser/projects/myapp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:309:15

So I thought of transpiling it because it looks like the ts files are not transpiled. When executing yarn tsc I get the following errors:

stack trace

node_modules/@types/react-native/globals.d.ts:36:15 - error TS2300: Duplicate identifier 'FormData'.

36 declare class FormData {
                 ~~~~~~~~

  node_modules/typescript/lib/lib.dom.d.ts:5078:11
    5078 interface FormData {
                   ~~~~~~~~
    'FormData' was also declared here.

node_modules/@types/react-native/globals.d.ts:66:3 - error TS2717: Subsequent property declarations must have the same type.  Property 'body' must be of type 'string | ArrayBuffer | ArrayBufferView | Blob | FormData | URLSearchParams | ReadableStream | null | undefined', but here has type 'string | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | Blob | FormData | null | undefined'.

66   body?: BodyInit_;
     ~~~~

node_modules/@types/react-native/globals.d.ts:92:14 - error TS2300: Duplicate identifier 'RequestInfo'.

92 declare type RequestInfo = Request | string;
                ~~~~~~~~~~~

  node_modules/typescript/lib/lib.dom.d.ts:17604:6
    17604 type RequestInfo = Request | string;
               ~~~~~~~~~~~
    'RequestInfo' was also declared here.

node_modules/@types/react-native/globals.d.ts:111:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'Response' must be of type '{ new (body?: string | ArrayBuffer | ArrayBufferView | Blob | FormData | URLSearchParams | ReadableStream | null | undefined, init?: ResponseInit | undefined): Response; prototype: Response; error(): Response; redirect(url: string, status?: number | undefined): Response; }', but here has type '{ new (body?: string | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | Blob | FormData | null | undefined, init?: ResponseInit | undefined): Response; prototype: Response; error: () => Response; redirect: (url: ...'.

111 declare var Response: {
                ~~~~~~~~

node_modules/@types/react-native/index.d.ts:9077:11 - error TS2451: Cannot redeclare block-scoped variable 'console'.

9077     const console: Console;
               ~~~~~~~

  node_modules/typescript/lib/lib.dom.d.ts:17295:13
    17295 declare var console: Console;
                      ~~~~~~~
    'console' was also declared here.

node_modules/@types/react-native/index.d.ts:9085:18 - error TS2717: Subsequent property declarations must have the same type.  Property 'geolocation' must be of type 'Geolocation', but here has type 'GeolocationStatic'.

9085         readonly geolocation: Geolocation;
                      ~~~~~~~~~~~

node_modules/@types/react-native/index.d.ts:9088:11 - error TS2451: Cannot redeclare block-scoped variable 'navigator'.

9088     const navigator: Navigator;
               ~~~~~~~~~

  node_modules/typescript/lib/lib.dom.d.ts:17191:13
    17191 declare var navigator: Navigator;
                      ~~~~~~~~~
    'navigator' was also declared here.

node_modules/typescript/lib/lib.dom.d.ts:5078:11 - error TS2300: Duplicate identifier 'FormData'.

5078 interface FormData {
               ~~~~~~~~

  node_modules/@types/react-native/globals.d.ts:36:15
    36 declare class FormData {
                     ~~~~~~~~
    'FormData' was also declared here.

node_modules/typescript/lib/lib.dom.d.ts:5088:13 - error TS2300: Duplicate identifier 'FormData'.

5088 declare var FormData: {
                 ~~~~~~~~

  node_modules/@types/react-native/globals.d.ts:36:15
    36 declare class FormData {
                     ~~~~~~~~
    'FormData' was also declared here.

node_modules/typescript/lib/lib.dom.d.ts:16316:11 - error TS2320: Interface 'Window' cannot simultaneously extend types 'GlobalFetch' and 'WindowOrWorkerGlobalScope'.
  Named property 'fetch' of types 'GlobalFetch' and 'WindowOrWorkerGlobalScope' are not identical.

16316 interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch, WindowOrWorkerGlobalScope, WindowEventHandlers {
                ~~~~~~

node_modules/typescript/lib/lib.dom.d.ts:17191:13 - error TS2451: Cannot redeclare block-scoped variable 'navigator'.

17191 declare var navigator: Navigator;
                  ~~~~~~~~~

  node_modules/@types/react-native/index.d.ts:9088:11
    9088     const navigator: Navigator;
                   ~~~~~~~~~
    'navigator' was also declared here.

node_modules/typescript/lib/lib.dom.d.ts:17295:13 - error TS2451: Cannot redeclare block-scoped variable 'console'.

17295 declare var console: Console;
                  ~~~~~~~

  node_modules/@types/react-native/index.d.ts:9077:11
    9077     const console: Console;
                   ~~~~~~~
    'console' was also declared here.

node_modules/typescript/lib/lib.dom.d.ts:17604:6 - error TS2300: Duplicate identifier 'RequestInfo'.

17604 type RequestInfo = Request | string;
           ~~~~~~~~~~~

  node_modules/@types/react-native/globals.d.ts:92:14
    92 declare type RequestInfo = Request | string;
                    ~~~~~~~~~~~
    'RequestInfo' was also declared here.

node_modules/typescript/lib/lib.dom.iterable.d.ts:67:11 - error TS2300: Duplicate identifier 'FormData'.

67 interface FormData {
             ~~~~~~~~

  node_modules/@types/react-native/globals.d.ts:36:15
    36 declare class FormData {
                     ~~~~~~~~
    'FormData' was also declared here.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Trancevercommented, Nov 9, 2018

@Jobeso Could you check if it still happens on 6.0.1-RC version?

@erandagan I didn’t so it was probably the issue.

0reactions
Jobesocommented, Nov 12, 2018

So I was able to use the master branch after forking and changing the package version to semver convention 6.0.2-rc.1. So I suggest handling upcoming rc versions like that. Before that yarn wouldn’t let me install from the repo. Now I am able to successfully build even with the ts errors on transpiling. Thanks for the help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

However, this package itself specifies a `main` module field ...
I got the same error above when I installed a new package and rebuild my app not knowing that I had to restart...
Read more >
Troubleshooting - React Navigation
However, this package itself specifies a "main" module field that could not be resolved ("/path/to/node_modules/@react-navigation/native/src/index.tsx"
Read more >
However, this package itself specifies a `main` module field ...
Solution : · Go to the iOS folder and do pod install . · Stop the metro server and restart it. · Delete...
Read more >
Angular compiler options
When false , constructor parameters of classes marked with @Injectable whose type cannot be resolved produce a warning. The recommended value is true...
Read more >
Oracle Database Error Messages
Oracle is not responsible for any loss or damage of any sort that you may incur ... locked by a client which is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found