1

When running npm build with:

"build": "browserify -t [ babelify --presets [ es2015 react ] ] app/assets/app.jsx -o public/javascripts/app.js"

I am getting following error:

Error: Cannot find module 'components/maininput.jsx' from 'C:\Users\Work\Documents\NetBeansProjects\Project\app\assets'

Project structure looks like this:

app
|
└────assets
    │   app.jsx
    |
    └───components 
           maininput.jsx

import in app.jsx looks like this:

import React from 'react';
import ReactDOM from 'react-dom';
import { MainInput } from '../components/maininput.jsx'

export in maininput.jsx looks like this:

export default class MainInput extends React.Component {
  //some code and render()
}

I also created GulpFile and also there getting same error:

{ Error: Cannot find module '../components/maininput.jsx'

EDIT: I have found out that it is working only if I provide full path to component, which is strange. Anyone knows what might cause this problem? Probably some enviroment variable or ?

Ľubomír
  • 1,075
  • 1
  • 12
  • 20

1 Answers1

2

Use ./ at the beginning of your import path:

import { MainInput } from './components/maininput.jsx'
bfontaine
  • 18,169
  • 13
  • 73
  • 107
fumihwh
  • 1,239
  • 7
  • 13