Including files from an outside directory


I have discovered that this actually occurs with just react-hot-loader, so I guess it has nothing to do with being in a module, eg:


import React from 'react';
import ReactDOM from 'react-dom';
import App from '../../react-dev-component/test/test-component';

ReactDOM.render(<App body="test" />, document.getElementById('root'));

Produces the same result, so does the module need to be in the same root path or something? Maybe is a babel loader problem?

Original issue

I am writing which is based on

The utility takes a specified file, eg: node server.js --component test/test-component.js, spins up a webpack server with react-hot-loader, and includes the file specified (admitidly, through a bit of a hack).

This works fine when you are developing locally, and the file you are including is in the webpack directory, but no longer works when you try to pass in a file that is outside the folder. Eg: node server.js --component ../eee/src/js/json-explorer/json-explorer.js or (when installed globally) react-dev-component --component src/js/json-explorer/json-explorer.js

Module parse failed: /Users/eriwoole/Projects/EEE/src/js/json-explorer/json-explorer.js Line 1: Unexpected token
You may need an appropriate loader to handle this file type.
| import React, {Component} from 'react'
| export default class JSONExplorer extends Component {
|   render () {
 @ ./src/index.js 17:20-97

Really stumped by this one.

Author: Fantashit

3 thoughts on “Including files from an outside directory

Comments are closed.