title: secretOrPrivateKey must have a value
body: <p>I am trying to learn nodejs and using jwt to create a token for a user. But I am getting this error on my server side:  <code>secretOrPrivateKey must have a value</code>. It is a lot of code so I am going to give what I think is important (let me know if you need anything else):</p>
  
  <p><strong>user.js:</strong></p>
  
  <pre><code>const config = require('./../config/config').get(process.env.NODE_ENV);
  ...
  userSchema.methods.generateToken = function(callback) {
      console.log(config.SECRET); // THIS IS UNDEFINED
      var token = jwt.sign(this._id.toHexString(), config.SECRET);
  
      this.token = token;
      this.save(function(err, user) {
          if (err) return callback(err);
          callback(null, user)
      });
  }
  </code></pre>
  
  <p><strong>server.js:</strong></p>
  
  <pre><code>app.post('/api/login', (req, res) =&gt; {
      User.findOne({'email': req.body.email}, (err, user) =&gt; {
          ...    
          user.generateToken((err, user) =&gt; {
              if (err) return res.status(400).send(err);
  
              res.cookie('auth', user.token).json({
                  isAuth: true,
                  id: user._id
              })
          })
      })
  })
  </code></pre>
  
  <p><strong>config.js:</strong></p>
  
  <pre><code>const config = {
      production: {
          SECRET: process.env.SECRET,
          DATABASE: process.env.MONGODB_URI
      },
      default: {
          SECRET: 'SUPER_SECRET-PASSWORD!123?',
          DATABASE: 'mongodb://localhost:27017/feedback'
      }
  }
  
  exports.get = function get(env) {
      return config[env] || config.default
  }
  </code></pre>