In js file, i used import to instead of require
import co from \'co\';
And tried to run it directly by nodejs since it said import is \'shi
It may be that you're running uncompiled files. Let's start clean!
In your work directory create:
A package.json file with the following object:
{
"scripts": {
"transpile-es2015": "babel src -d lib"
},
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-preset-latest": "^6.16.0"
}
}
A file named ".babelrc" with the following instructions:
{"presets": ["latest"]}
Lastly, write test code in your src/index.js file. In your case:
import co from 'co'.
Through your console:
npm install
npm run transpile-es2015
node lib/index.js