React Server

“TypeError: Cannot read property ‘then’ of undefined ” on running yo react server

React server is a framework for creating pages which load faster and also perform well during page transitions. It was recently that I stumbled across this framework. Out of curiosity I tried installing the react server but encountered quite some issues. In this quick tutorial, I’ll point out how to resolve the above issue and get started with react server.

React server required yeoman to be installed. So, first I installed the yeoman and react server generator using the following commands :


# install yeoman
npm install -g yo

# install the react-server generator
npm install -g generator-react-server

Till now all looked good. Next in order to create the the react server app, I ran the following command:


# make a new react-server project in the CURRENT directory
yo react-server

The above command should have ideally created the react server project but it instead threw the following error :


[?] What would you like to call your app? (RS) events.js:141
throw er; // Unhandled 'error' event
^

TypeError: Cannot read property 'then' of undefined
at Base.prompt (/usr/lib/node_modules/generator-react-server/node_modules/yeoman-generator/lib/base.js:232:44)
at module.exports.yeoman.Base.extend.prompting (/usr/lib/node_modules/generator-react-server/generators/app/index.js:35:15)
at Object. (/usr/lib/node_modules/generator-react-server/node_modules/yeoman-generator/lib/base.js:431:23)
at /usr/lib/node_modules/generator-react-server/node_modules/run-async/index.js:26:25
at /usr/lib/node_modules/generator-react-server/node_modules/run-async/index.js:25:19
at /usr/lib/node_modules/generator-react-server/node_modules/yeoman-generator/lib/base.js:432:9
at processImmediate as _immediateCallback

The above is error was due to an older version of yo running on my Ubuntu Box. Simply running the following command gave me the yo version installed on my linux box.


yo --version   # 1.1.2

In order to update yo I tried doing an npm update.


npm -g update yo

The above command didn’t quite worked for me. So, I tried uninstalling yo.


npm -g uninstall yo

I tried checking if yo was still installed by typing :


yo --version

yo was still very much alive and installed. I tried checking where the yo was installed by doing a which command.


which yo

And it showed me the path where yo was still existing.


/usr/local/bin/yo

So, I removed yo from that path and installed it again. And this time it got installed, but in a different path.


/usr/bin/yo

I exported the path where yo was newly installed and ran the command to create the project and run the app.



export PATH=$PATH:/usr/bin/yo

# make a new react-server project in the CURRENT directory
yo react-server

# run the new app
npm run start
# go to http://localhost:3000