10

ftw !!!! js sucks
importing js files giving errors 😐
used require(blah_blah) and
import { blah_blah as blah } from blah

How do I do it ?😶

Comments
  • 2
    Do you mean nodejs or just plain js?

    if(answer === "JavaScript"){
    console.log("https://stackoverflow.com/questions...");
    }elseif(answer === "nodejs"){
    console.log("https://stackoverflow.com/questions...");
    }else{
    console.log("try reading docs of the thing you are using");
    }
  • 2
    OGM js sucks! Dafuq man, try to import in python.

    I believe you wanted to say omg I suck at js.
  • 2
    How to not ask a programming question, by OP.

    If you want a good reply you naught need to tell us emphasis("what") is happening and emphasis("what") you're doing.

    "My code aint workin'" isn't enough.
    "This code I wrote aint workin'"is better
    "This code aint workin' I'm gettin' this error:" is better
    "This code aint workin', I'm gettin' this errpr and I've tried this this and that and it aint workin'" is the best
  • 1
    @inaba i am trying web3js, truffle and importing them into my app. see the pic
    but in console it is giving me error: unexpected token
  • 1
    @adeshgautam man I don't know if you are using some fancy webpack plugin but I don't think you are doing import correctly.

    You want to drop those curly since u are using default anyhow or use as outside of them:

    import default as yourname from 'module'

    Or import { exportedName } as yourname from 'module'

    Also do not mix require and import.
  • 1
    @donnico finally fixed it... thankx for helping
  • 2
    @adeshgautam I double checked and you actually can use as inside the curly, but now with default.

    Protip: you can always use import * as all from 'yourmodule'

    And then console.log(all) and you can see the structure of your module completely.
Add Comment