Giter VIP home page Giter VIP logo

Comments (15)

jvduf avatar jvduf commented on August 15, 2024

We can do a check on the window but that's not always safe..

  if (typeof window === 'undefined') {
    nodejs = true;
  }

from weld.

tmpvar avatar tmpvar commented on August 15, 2024

a try catch around https://github.com/hij1nx/weld/blob/master/lib/weld.js#L61-64 should do the trick, you up to it?

from weld.

jvduf avatar jvduf commented on August 15, 2024

Tried that but didn't work. Still throws that error for some reason... Think it's something in Browserify that forces the error.

(might be doing something wrong as I am still a beginner with Node.js)

Could ask Substack to change Browserify so it allows for try/catch

from weld.

heapwolf avatar heapwolf commented on August 15, 2024

try this syntax exactly:

(require)("weld")

from weld.

jvduf avatar jvduf commented on August 15, 2024

Same error even with that syntax...

var weld = (require)("weld").weld;

from weld.

heapwolf avatar heapwolf commented on August 15, 2024

I figured this out, should have a patch pretty quick.

from weld.

jvduf avatar jvduf commented on August 15, 2024

We need this patch in Nodejitsu admin for some secret stuff ;) Current implementation is breaking stuff and I have to jump through some hoops to get it running in production.

Could you patch this in the NPM module?

from weld.

heapwolf avatar heapwolf commented on August 15, 2024

im not sure exactly what are you talking about, can you gist the patch you need?

from weld.

jvduf avatar jvduf commented on August 15, 2024
  if (typeof require !== 'undefined') {
    var tty = require('tty');
    if (tty.isatty && tty.isatty(0)) { 
      // if this is still a browser, they are trying really hard.
      nodejs = true;
    }
  }

This does not work in the browser because browserify does not allow require('tty'). So instead I am using a very simple check:

if (typeof window !== 'undefined') nodejs = true;

from weld.

cjroebuck avatar cjroebuck commented on August 15, 2024

hey, any update on a patch for this yet? Whats the best workaround in the mean time to get this working in browserify? The problem is checking for require doesn't discriminate between server/client when running a script loader such as browserify.

from weld.

heapwolf avatar heapwolf commented on August 15, 2024

this is fixed in 76b9821

from weld.

cjroebuck avatar cjroebuck commented on August 15, 2024

Hmm, Its not fixed. Still getting the Error: No wrapper for core module tty message when requiring it through browserify.

Thanks

from weld.

heapwolf avatar heapwolf commented on August 15, 2024

@tmpvar hey, you overwrote my fix with your fix, so im assuming your fix must have been better than mine =) looks like it didn't get tested completely?

from weld.

tmpvar avatar tmpvar commented on August 15, 2024

which one of your commits did I overwrite?

from weld.

heapwolf avatar heapwolf commented on August 15, 2024

i cant remember, but the idea i had for checking against node was...

(process && process.title === 'node')

from weld.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.