finos / perspective

A data visualization and analytics component, especially well-suited for large and/or streaming datasets.
https://perspective.finos.org/
Apache License 2.0
8.28k stars 1.15k forks source link

Error: Cannot find module 'stoppable' #2183

Closed Khalilsqu closed 1 year ago

Khalilsqu commented 1 year ago

Bug Report

Steps to Reproduce:

  1. Next JS app
  2. No use of npm perspective-webpack-plugin
  3. import * as perspective from "@finos/perspective";

I keep getting this error

image

import * as perspective from "@finos/perspective";

export default function Students() {
  return <h1>Students</h1>;
}
sinistersnare commented 1 year ago

This looks unrelated to Perspective. Post full source code please.

yangjunhan commented 1 year ago

Hi, @Khalilsqu. I encountered the same problem. Looks like the latest upgrade (v2.0.0) of Perspective introduced a new dependency. Try npm i -D stoppable and put it in your webpack plugin custom config:

webpackConfig.resolve.fallback = {
    stoppable: require.resolve('stoppable')
  };

This helped me resolve this issue.

Khalilsqu commented 1 year ago

@yangjunhan thanks for the help. However, I am not exactly aware how to configure webpack! where does it go?

is this how is it? next.config.js

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  webpack: (config, options) => {
    config.resolve.fallback = {
      stoppable: require.resolve("stoppable"),
    };
    return config;
  },
};

module.exports = nextConfig;
texodus commented 1 year ago
  1. Next JS app

@Khalilsqu This is not an adequate repro. I don't know even which version of the library you are trying to import - webpack and the perspective module that imports stoppable (node.js) are mutually exclusive AFAIK.

This dependency does look like its missing so I'll add it, but as you've provided no repro I can't verify it does anything for you, so closing. Please use the error template and provide as much detail as possible when you file issues in the future.

riziles commented 1 year ago

@texodus , I have been able to replicate simply by upgrading to Perspective 2.2.1 in a deployment that was working fine on 1.9.4. Please see pull request here: https://github.com/riziles/svelte-perspective-starter1/pull/2 the Vercel preview deployments show server errors. The log files all point to the missing stoppable dependency.

FWIW, I'm using Vite (via SvelteKit), not Webpack. Installing stoppable resolves the issue without having to alter any config files.