Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

TypeScript project fails to build; module 'web3/providers' not found #465

@hrharder

Description

@hrharder

As of a few days ago, a TypeScript project I am working on suddenly started failing, reporting an issue originating from node_modules/ganache-core/typings/index.d.ts (see full error below).

The issue appears to be the typings/index.d.ts file imports some types from package web3/providers, which really should just be web. This PR addresses that. I was able to confirm the change solves my problem

Expected Behavior

The project should build with no error.

Current Behavior

The project fails to build with tsc with the following error:

$ tsc
node_modules/ganache-core/typings/index.d.ts:2:44 - error TS2307: Cannot find module 'web3/providers'.

2   import { Provider as Web3Provider } from "web3/providers";
                                             ~~~~~~~~~~~~~~~~
Found 1 error.

Possible Solution

Before

// from typings/index.d.ts

declare module "ganache-core" {
  import { Provider as Web3Provider } from "web3/providers";

  namespace Ganache {
    export interface IProviderOptions {
// ...

After

// from typings/index.d.ts

declare module "ganache-core" {
  import { Provider as Web3Provider } from "web3";

  namespace Ganache {
    export interface IProviderOptions {
// ...

Steps to Reproduce (for bugs)

  1. Clone this project.
  2. Run yarn to install dependencies (of which ganache-core is one)
  3. Run yarn build to build the TypeScript source
  4. See the error above

Context

Our project fails to build locally and in CI environments, prohibiting us from continuing to integrate changes into our codebase.

Your Environment

  • Version used: 2.7.0
  • Environment name and version:
    • Node.js LTS (10.15.3)
    • TypeScript (3.5.3)
    • Yarn (1.17.3)
  • Operating System and version:
    • MacOS (darwin)
    • Linux
  • Link to your project:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions