NodeJs : TypeError: require(…) is not a function

前端 未结 7 927
旧巷少年郎
旧巷少年郎 2020-11-27 15:27

I am trying to require a file and afterwards pass it to a var. I am following this tutorial to create a authentication system. After writing the server.js file and trying to

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 15:58

    For me, when I do Immediately invoked function, I need to put ; at the end of require().

    Error:

    const fs = require('fs')
    
    (() => {
      console.log('wow')
    })()
    

    Good:

    const fs = require('fs');
    
    (() => {
      console.log('wow')
    })()
    

提交回复
热议问题