Client on node: Uncaught ReferenceError: require is not defined

前端 未结 8 1455
遥遥无期
遥遥无期 2020-11-21 07:20

So, I am writing an application with the node/express + jade combo.

I have client.js, which is loaded on the client. In that file I have code that calls

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-21 08:19

    Even using this won't work , I think the best solution is browserify:

    module.exports = {
      func1: function () {
       console.log("I am function 1");
      },
      func2: function () {
        console.log("I am function 2");
      }
    };
    
    -getFunc1.js-
    var common = require('./common');
    common.func1();
    

提交回复
热议问题