app.set('port', port) 'TypeError: undefined is not a function'. Beginner, need ideas

后端 未结 6 931
春和景丽
春和景丽 2021-02-04 04:12

I\'m an amateur learning to build with node.js. I\'ve been following a tutorial to create my first node.js app. It worked perfectly until I entered \'npm start\'. The log is:

6条回答
  •  囚心锁ツ
    2021-02-04 04:48

    In my case I simply moved the normalizePort function before the function was called. This was in coffeescript but I've converted it to javascript here.

    normalizePort = function(val) {
      var port;
      var port;
      port = parseInt(val, 10);
      if (isNaN(port)) {
        return val;
      }
      if (port >= 0) {
        return port;
      }
      return false;
    };
    
    port = normalizePort(process.env.PORT || '4000');
    

提交回复
热议问题