Error: Cannot find module 'three' #488
-
I'm trying to add postprocessing to a website including three & three-nebula and which is bundled with Webpack. Unfortunately I'm getting an error saying The error is occurring from this file: import { Event, Object3D, PerspectiveCamera, PointLight, Scene } from "three";
import {Selection, SelectiveBloomEffect} from 'postprocessing';
function createStrandLight(scene: Scene, camera: PerspectiveCamera, objs: Object3D<Event>[]) {
const bloom = new SelectiveBloomEffect(scene, camera, {
intensity: 1.5,
luminanceThreshold: 0.0001,
mipmapBlur: true,
});
bloom.selection = new Selection(objs);
const lights: PointLight[] = [];
for (const bulb of objs) {
const color = bulb.name.split('-')[1] ?? 'white';
const light = new PointLight(color, 6, 0, 2);
const { x, y, z } = bulb.position;
light.position.set(x, y-0.15, z);
lights.push(light);
scene.add(light);
}
return {bloom, lights}
}
export {createStrandLight} And my webpack config is: import * as path from 'path'
export default {
mode: 'development',
entry: './src/main.ts',
devServer: {
port: 9000,
static: {
serveIndex: true,
directory: __dirname
}
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/dist/'
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/
},
]
},
watchOptions: {
ignored: /node_modules/
}
} The full output of the error is:
Does anyone have any idea as to why this error is occurring? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Did you install the peer dependency |
Beta Was this translation helpful? Give feedback.
-
In my particular case changing the module type to Example: {
"compilerOptions": {
"lib": [
"es2015",
"dom"
],
"resolveJsonModule": true,
"esModuleInterop": true,
"sourceMap": true,
"declaration": false,
"module": "ESNext",
"moduleResolution": "node",
"target": "es2015"
"strict": true,
}
} |
Beta Was this translation helpful? Give feedback.
In my particular case changing the module type to
ESNext
in my typescript config resolved the issue.Example: