// a.js
module.exports = "a";
// index.js
import a from "./a"
console.log(a);
// .babelc
{
"presets": [
["env", {
"targets": {
"node": "current"
}
}]
]
}
execute using the following statement:
babel-node index.js
the following error occurred:
/usr/local/lib/node_modules/babel-cli/node_modules/_babel-core@6.26.3@babel-core/lib/transformation/file/options/option-manager.js:328
throw e;
^
Error: Cannot find module "globals" (While processing preset: "/Users/xuyuechao/Work/other-git-project/babel/node_modules/_babel-preset-env@1.7.0@babel-preset-env/lib/index.js")
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/xuyuechao/Work/other-git-project/babel/node_modules/_babel-traverse@6.26.0@babel-traverse/lib/scope/index.js:53:16)
at Module._compile (module.js:652:30)
at Module._extensions..js (module.js:663:10)
at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/babel-cli/node_modules/_babel-register@6.26.0@babel-register/lib/node.js:152:7)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)