Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a wrong #2

Closed
zhaodagang opened this issue May 23, 2018 · 7 comments
Closed

There is a wrong #2

zhaodagang opened this issue May 23, 2018 · 7 comments

Comments

@zhaodagang
Copy link

test.js
require("babel-register");
let model = require("./mm.js");

mm.js
let a = {
t:11,
t2:22

}
export default a;

PS F:\node> node test
F:\node\mm.js:8
export default a;
^^^^^^

SyntaxError: Unexpected token export
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at loader (F:\node\node_modules_babel-register@6.26.0@babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (F:\node\node_modules_babel-register@6.26.0@babel-register\lib\node.js:154:7)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)

@Cap32
Copy link
Owner

Cap32 commented May 23, 2018

  1. You're using babel-register, but not babel-register-cli
  2. You need babel-plugin-transform-es2015-modules-commonjs to transform ES modules

@Cap32 Cap32 closed this as completed May 23, 2018
@zhaodagang
Copy link
Author

I install babel-register, babel-register-cli babel-plugin-transform-es2015-modules-commonjs

It is still wrong .
Like up these code,how I shoud do?

@Cap32
Copy link
Owner

Cap32 commented May 23, 2018

Did you use the babel plugin via .babelrc?

@zhaodagang
Copy link
Author

i only think oprate es6 code in node.js,

@zhaodagang
Copy link
Author

For example , in node.js like this:
import a from 'bb.js'

How do?

@zhaodagang
Copy link
Author

我只是想在nodde.js中,使用 import 或者 export等es6.
应该怎么做,告诉我下使用流程。

@Cap32
Copy link
Owner

Cap32 commented May 23, 2018

You may need this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants