frostney / react-native-create-library

:notebook: Command line tool to create a React Native library with a single command
MIT License
1.45k stars 113 forks source link

SyntaxError: Unexpected token #6

Closed esutton closed 8 years ago

esutton commented 8 years ago

Wow! This will be a great time saver! Thank you for sharing a great tool!

I am getting this error when I create a new project:

npm install -g react-native-create-library
react-native-create-library MyBridgeModule

/Users/edward3/.nvm/versions/node/v5.9.1/lib/node_modules/react-native-create-library/lib.js:8
const { hasPrefix, createFile, createFolder } = require('./utils');
      ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/Users/edward3/.nvm/versions/node/v5.9.1/lib/node_modules/react-native-create-library/cli.js:4:23)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
frostney commented 8 years ago

Hi @esutton, I'm seeing you are running Node 5.9.1 through NVM. Unfortunately this tool right now requires at least Node.js 6.0. Is using Node.js 6.0+ an option for you?

esutton commented 8 years ago

@frostney Thank you for the quick reply.

Do you know if Node.js 6.0 should be a painless upgrade for react native ?

I will read about how to upgrade Node.js

frostney commented 8 years ago

You should be able to use Node 6.x side-by-side to Node 5 with NVM. nvm install 6

You can instruct NVM to only use Node 6 to create a library with this tool by doing nvm exec 6 react-native-create-library MyBridgeModule

If that doesn't work, try:

nvm use 6 // Switch to Node 6 first
react-native-create-library MyBridgeModule // Create library
nvm use 5 // Switch back to Node 5

I realize that both of that is not a perfect solution. Let me know if it works for you.

I haven't run into any issues with Node 6 and React Native, but to be honest I try to always be on the latest React Native version.

esutton commented 8 years ago

That sounds great. I will give it a try.

Thank you for the details on installing and switching.

esutton commented 8 years ago

Thank you for tips on nvm and Node.

Works great.

Thank you for sharing your work.