Deployment has stopped working

Today has been a bad day all round and as a last ditch attempt to make myself feel better I figured I’d try removing my node_modules directory with rm -rf node_modules and then just build for a production release:

npm install --prod

This would give me a nice svelte set of functions that I could push up to AWS. Problem is? It went up but I started getting the following error:

Unable to import module 'lib/authorize': Error
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/task/lib/oauth.js:2:1)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/task/lib/authorize.js:3:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)

Note: the authenticate function is my own function and it’s small and been working for a long time

Ok, so I figured I was trying to be too fancy (my 32mb function was now only 3mb). Admittedly 3mb is closer to what it should be but that’s an open issue. Anyway I went back to the full set of deps (dev and prod) and back to 32mb. Unfortunately the same error keeps on happening. What is going on?

Now one other thing … I noticed that I have updated to the Serverless Framework version 1.2.1 which actually was not intended (I had been on 1.1 prior) … it’s possible that this is part of the puzzle.

For anyone that feels they need to see the authenticate module, here it is:

Note: I have validated that all the “require” statements are represented in node_modules (or locally in “lib”) from the AWS Lambda download that I took to investigate

"use strict";
var Promise = require('bluebird');
var oauth = require('./oauth');
require('./defn');
var _ = require('lodash');
exports.handler = function (event, context, cb) {
    context.callbackWaitsForEmptyEventLoop = false;
    console.log('EVENT:\n', JSON.stringify(event, null, 2));
    var uid = _.get(event, 'queryStringParameters.uid', undefined);
    if (!uid) {
        cb(null, {
            statusCode: 412,
            body: 'no TrueCash User ID was provided by frontend'
        });
        return;
    }
    oauth.getRequestToken(uid)
        .then(function (token) {
        console.log('Token is:\n', JSON.stringify(token, null, 2));
        console.log('User ID: ', uid);
        console.log('URL: ', token.url);
        token.uid = uid;
        return Promise.resolve(token);
    })
        .then(function (token) {
        cb(null, {
            statusCode: 200,
            body: JSON.stringify({ url: token.url }),
            headers: {
                'Content-Type': 'application/json',
            },
        });
        return;
    })
        .catch(function (err) {
        console.log('Problem in getting promise token: ', err);
        cb(null, {
            statusCode: 500,
            body: String(err) || err.message,
        });
    });
};

I have now rolled back to 1.1.0 and the same error is occurring. I’m at a complete loss why my full rollback is no longer working.

I’m closing this because I found that in the eagerness to reduce file size I had removed a package from package.json which was still being referenced.

Well actually I guess there is no way to “close” this but please consider it closed. :slight_smile: