I have an app that contains the following in index.js
:
import express from 'express';
import data from './data/data.json';
const app = express();
const PORT = 3000;
How can I access the data
variable for testing purposes?
This answer given on SO (node -i -e "$(< index.js)"
) returns the following error:
import express from 'express';
^^^^^^^
SyntaxError: Unexpected identifier
I'm on Node 10.8 and Express 4.16.3.
In Rails, you're given an interactive console (by running rails console
) where you can "play around" with the environment (db et al).