spite / THREE.MeshLine

Mesh replacement for THREE.Line
MIT License
2.13k stars 379 forks source link

WARNING: Multiple instances of Three.js being imported. #156

Closed liorGameDev closed 1 year ago

liorGameDev commented 1 year ago

image

I get this error when trying to use three.meshline I think it is because TTHREE.Meshline imports three.cjs and not three.module.js - is there a way to enforce three.meshline to import three.module.js?

Zerhogi commented 1 year ago

It looks like you can get rid of warning by adding alias in your webpack config, in this case your main three.js and three.js from meshline will be imported from the same place

const path = require('path');

module.exports = {
    resolve: {
        alias: {
            three: path.resolve(__dirname, 'node_modules/three')
        },
    },
};
wellcaffeinated commented 1 year ago

I ran into this too with vite. For anyone else with this problem:

// vite.config.js
import { defineConfig } from 'vite'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [],
  resolve: {
    alias: {
      'three/examples': path.resolve(__dirname, 'node_modules/three/examples/'),
      three: path.resolve(__dirname, 'node_modules/three/build/three.module.js'),
    },
  },
})
liorGameDev commented 1 year ago

@wellcaffeinated Worked for me!