Skip to content

Module not found: Can't resolve 'vis-network/dist/types/vis-types' in '/home/jamie/programs/vis-test/src' #76

@jamietwells

Description

@jamietwells

Hi, I seem to be unable to use the DataSet.

Steps to reproduce:

Run the commands:

yarn create react-app vis-test --typescript
cd vis-test
yarn add vis-data
yarn add vis-network

Replace the src/App.tsx file with the following:

import React from 'react';
import './App.css';
import { Network } from 'vis-network';
import { DataSet } from 'vis-network/dist/types/vis-types';

class App extends React.Component<{}, { networkElement?: HTMLDivElement }> {
  constructor(props: {}) {
    super(props);
    this.state = {};
  }
  
  render() {
    const instance = this;

    if (instance.state.networkElement) {
      const nodes = new DataSet([{ id: 'a' }, { id: 'b' }]);
      const edges =  new DataSet([{ from: 'a', to: 'b' }]);
      const data = { nodes, edges };
      new Network(instance.state.networkElement, data);
    }

    function refCallback(elem: HTMLDivElement | null) {
      if (elem && !instance.state.networkElement)
        instance.setState({ networkElement: elem });
    }

    return (
      <div className="App">
        <div ref={refCallback} ></div>
      </div>
    );
  }
}

export default App;

run the command:

yarn start

See runtime error:

Failed to compile.

./src/App.tsx
Module not found: Can't resolve 'vis-network/dist/types/vis-types' in '/home/jamie/programs/vis-test/src'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions