teelou teelou - 9 months ago 31
Node.js Question

ES6 - Duplicate declaration on importing files

in pre-es6:

var stream = require("./models/stream");
var stream = require("./routes/stream");

It works fine.

In es6:

import stream from './models/stream';
import stream from './routes/stream';


TypeError: /var/www/.../es6/app.js: Duplicate declaration "stream"
> 31 | import stream from './routes/stream';

Any ideas how can I import it properly?


You are re-declaring the stream variable and never use it, so you can just import first file without assignment:

import './models/stream';
import stream from './routes/stream';