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

Node version? #3

Open
bradparks opened this issue Feb 2, 2019 · 3 comments
Open

Node version? #3

bradparks opened this issue Feb 2, 2019 · 3 comments

Comments

@bradparks
Copy link

Hey... Thanks for cool looking lib!

I'm a noob in node, but have run other ink stuff fine.... but when I try and npm install then node test.js or node examples/basic.js, i get an error:

/Users/bparks/gitrepos/cli_search/ink-autocomplete/examples/basic.js:1
(function (exports, require, module, __filename, __dirname) { import {h, render, Component, Text} from 'ink'
                                                              ^^^^^^
SyntaxError: Unexpected token import

I've tried nvm for node versions 7-11, but no luck.... I said noob, right??

;-)

Thanks!

@raulfdm
Copy link

raulfdm commented Dec 26, 2019

@bradparks That's because you're trying to run a "non node code" with node.

I'm not sure if you already figure it out but you can know more about this issue here:
https://adrianmejia.com/getting-started-with-node-js-modules-require-exports-imports-npm-and-beyond/#Imports

if you want to make the code run, you can use babel-node and create a config file to use @babel/preset-react and @babel/preset-env.

@bradparks
Copy link
Author

gotcha.... thanks for the info! Much appreciated!

@raulfdm
Copy link

raulfdm commented Dec 27, 2019

No problem! Glad to help.

Just a thing I found today: https://github.com/alangpierce/sucrase

Basically instead run node index.js you're gonna run sucrase-node index.ts and all these ESM, new features not supported by node (yet), will be supported by default.

Under the hood it has some configs. Looks promising and avoid this kind of erros! 😄

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