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

Module is not node-ready #31

Open
dasilvacontin opened this issue May 31, 2016 · 3 comments
Open

Module is not node-ready #31

dasilvacontin opened this issue May 31, 2016 · 3 comments

Comments

@dasilvacontin
Copy link
Contributor

ReferenceError: window is not defined
/Users/dasilvacontin/temp/node_modules/gh-emoji/dist/gh-emoji.js:55
  var fetch = window.fetch || function (endpoint) {
              ^
@zzarcon
Copy link
Owner

zzarcon commented May 31, 2016

Hi @dasilvacontin I know, the module is not compatible with Node.js right now. Actually I didn't thought about that use case... If I get your point you would like to use gh-emoji in your Node app in order to return html with the github emojis as img tags?

Just wondering about how helpful might be to support Node, but we can do it for sure!

@dasilvacontin
Copy link
Contributor Author

@zzarcon For now I was just doing a proof of concept for my website redesign in which I fetch all my public repos, and parse the emoji in the repos' description. I was currently logging the result to the terminal. (or trying to)

It can be useful for trying out the library, creating CLI and pre-rendered/static content (in which parsing the emojis in the browser will be unnecessary overhead).

@dasilvacontin dasilvacontin changed the title Module is not node-ready: window is not defined Module is not node-ready May 31, 2016
@dawsbot
Copy link

dawsbot commented Nov 26, 2016

Chiming in to let you know this module cannot be server-rendered. In building an isomorphic react app, I cannot hand off the rendering from the server to the client because window fails in node. Can you use a conditional to ensure window exists?

I wanted to take care of implementing this and PR it, but out of the box, tests fail on my system.


Here's my system information and what steps I followed.

  1. npm install
  2. npm test
> [email protected] test /private/tmp/gh-emoji
> npm run test:browser


> [email protected] test:browser /private/tmp/gh-emoji
> browserify -t babelify ./test | tape-run | tap-spec

SyntaxError: /private/tmp/gh-emoji/src/index.js: Unexpected token, expected ; (19:49)
  17 |   */
  18 |
> 19 | const fetch = window.fetch || (endpoint: string) : Promise <Object> => {
     |                                                  ^
  20 |   return new Promise((resolve, reject) => {
  21 |     const xhr = new XMLHttpRequest();
  22 |
    at Parser.pp$5.raise (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:4246:13)
    at Parser.pp.unexpected (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:1627:8)
    at Parser.pp.semicolon (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:1608:38)
    at Parser.pp$1.parseVarStatement (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:2037:8)
    at Parser.pp$1.parseStatement (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:1729:19)
    at Parser.parseStatement (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:5218:22)
    at Parser.pp$1.parseBlockBody (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:2133:21)
    at Parser.pp$1.parseTopLevel (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:1645:8)
    at Parser.parse (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:1537:17)
    at parse$1 (/private/tmp/gh-emoji/node_modules/babylon/lib/index.js:6466:37)
stream.js:74
      throw er; // Unhandled stream error in pipe.
      ^

Error: javascript required
    at Stream.<anonymous> (/private/tmp/gh-emoji/node_modules/browser-run/index.js:27:34)
    at _end (/private/tmp/gh-emoji/node_modules/through/index.js:65:9)
    at Stream.stream.end (/private/tmp/gh-emoji/node_modules/through/index.js:74:5)
    at Stream.method [as end] (/private/tmp/gh-emoji/node_modules/duplexer/index.js:47:39)
    at Stream.<anonymous> (/private/tmp/gh-emoji/node_modules/throughout/index.js:7:25)
    at _end (/private/tmp/gh-emoji/node_modules/through/index.js:65:9)
    at Stream.stream.end (/private/tmp/gh-emoji/node_modules/through/index.js:74:5)
    at Stream.onend (stream.js:59:10)
    at emitNone (events.js:91:20)
    at Stream.emit (events.js:185:7)



npm ERR! Darwin 15.6.0
npm ERR! argv "/Users/dawsonbotsford/.nvm/versions/node/v6.2.1/bin/node" "/Users/dawsonbotsford/.nvm/versions/node/v6.2.1/bin/npm" "run" "test:browser"
npm ERR! node v6.2.1
npm ERR! npm  v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! [email protected] test:browser: `browserify -t babelify ./test | tape-run | tap-spec`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:browser script 'browserify -t babelify ./test | tape-run | tap-spec'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the gh-emoji package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     browserify -t babelify ./test | tape-run | tap-spec
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs gh-emoji
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls gh-emoji
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /private/tmp/gh-emoji/npm-debug.log
npm ERR! Test failed.  See above for more details.

sist output:

OS

Darwin
x64

shell

uname: Darwin
echo $SHELL: /bin/zsh
echo $TERM: xterm-256color
echo $TERM_PROGRAM: iTerm.app

node

npm -v: 3.10.9
node --version: v6.2.1

Time created: Fri Nov 25 2016 20:27:13 GMT-0800 (PST)

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

3 participants