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

怎么用?大佬 example调试就报错啊,貌似编辑器不支持模块的语法 ,怎么解决 #1

Open
dsy525 opened this issue Aug 26, 2017 · 6 comments

Comments

@dsy525
Copy link

dsy525 commented Aug 26, 2017

用babel转译下,只能转译一部分,总之就是用不成

@plantain-00
Copy link
Owner

Which environment do you use this in? nodejs or browser?
What's your reproducible code?
What's your error message?

@dsy525
Copy link
Author

dsy525 commented Aug 26, 2017

nodejs/webstrom11.0

import JsExcelTemplate from "js-excel-template/nodejs/nodejs";
^^^^^^

SyntaxError: Unexpected token import
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Timeout.Module.runMain [as _onTimeout] (module.js:604:10)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)

I search for the use of the import, I found my editor does not support。
I use the Babel translation js-excel-template this project,But it seems can only transfer part of the file,

@plantain-00
Copy link
Owner

I believe it's out of scope of this library, you may need a babel plugin like: http://babeljs.io/docs/plugins/transform-es2015-modules-commonjs/
Or refer to this question: https://stackoverflow.com/questions/33604470/unexpected-token-import-in-nodejs5-and-babel

@dsy525
Copy link
Author

dsy525 commented Aug 26, 2017

I did as you said ,but can‘t run,For a primary noder seems to be difficult to use,only be able to use the module after require。

@plantain-00
Copy link
Owner

plantain-00 commented Aug 26, 2017

@dsy525
Copy link
Author

dsy525 commented Aug 28, 2017

wow ! wow! it works, Thank you very much dalao, your model very very helpful to me,.thanks again

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

No branches or pull requests

2 participants