I have created a reactjs/webpack app with an component created in main.js:
import React from 'react'; import cube from 'my-module'; class MainLayout extends React.Component { constructor(props) { super(props); console.log('testing=main constructor') console.log(cube(3)); } render() { console.log('main render' ) return ( <div>hello</div> ); } } export default MainLayout I am trying to get my head around import and export in es6 and created a module in the same directory:
// module "my-module.js" export default function cube(x) { return x * x * x; } However I am getting this error:
ERROR in ./app/components/layouts/main/main.js Module not found: Error: Cannot resolve module 'my-module' in ... How can I resolve this error?