2

Getting this error from serverless-webpack:

ERROR in ../db/actions/index.js
Module not found: Error: Can't resolve 'amazon-dax-client' in '/var/task/db/actions'
 @ ../db/actions/index.js 2:24-52
 @ ../db/db.js
 @ ./crop.js

My webpack.config.js file contains:

const slsw = require('serverless-webpack')

module.exports = {
    entry: slsw.lib.entries,
    target: 'node',
    externals: {
        sharp: 'commonjs sharp',
    },
    // Run babel on all .js files and skip those in node_modules
    module: {
        rules: [{
            test: /\.js$/,
            loader: 'babel-loader',
            include: __dirname,
            exclude: /node_modules/,
        }]
    }
}

The amazon-dax-client module is present in node_modules.

I've rolled back to the last versions of webpack and serverless-webpack that worked for me:

"serverless-webpack": "4.3.0",
"webpack": "3.11.0"

Any ideas on how to resolve or to get additional logging output to track down the issue?

3 Answers 3

1

Alternatively, you may consider using node-prune to remove unnecessary files from node_modules (.md, .ts, ...) It would not be as effective as webpack but it's way less complicated and definitely not error-prone. It can be good enough for certain projects.

Sign up to request clarification or add additional context in comments.

Comments

0

Can you try removing the /node_modules/ exclusion? If that's removed, I'd imagine it'd be able to get into that folder and do what you need. Since amazon-dax-client is in that folder, and you're telling webpack to ignore the node_modules folder, it won't be able to reach it. Let me know if that helps.

2 Comments

I commented out that line, and got the same result.
Can you share your file structure with me and point out your entry point? I have an idea as to what might be going on.
0

I'm no longer getting the error, although I can't say specifically what fixed it. Deleting package-lock.json and node_modules seemed to be the catalyst.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.