Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error including local npm module #93

Open
janoist1 opened this issue Jan 23, 2021 · 0 comments
Open

Error including local npm module #93

janoist1 opened this issue Jan 23, 2021 · 0 comments

Comments

@janoist1
Copy link

janoist1 commented Jan 23, 2021

I'm getting errors when using local npm package:

...
"common": "file:../common",
...
Serverless: Packing external modules: aws-sdk@^2.270.1, uuid@^8.3.2, ramda@^0.27.1, common@file:../common, atob@^2.1.2, es6-promisify@^6.1.1, btoa@^1.2.1, node-forge@^0.10.0, slugify@^1.4.6, node-ses@^3.0.3, request-promise-native@^1.0.7, request
Serverless: WARNING: Could not determine version of module request
 
  Error --------------------------------------------------
 
  Error: ENOENT: no such file or directory, stat '/Users/i/Dev/name-of-project/api/.webpack/dependencies/node_modules/common'

I'm pulling my hair as Serverless ecosystem keeps throwing 'random' errors at me. This is the most recent one blocking me.

Serverless: 1.83.2
"copy-webpack-plugin": "^6.1.1",
"serverless-webpack": "^5.3.5",
"webpack": "^4.44.2",
"webpack-node-externals": "^2.5.2"

serverless.yml:

  webpack:
    webpackConfig: ./webpack.config.js
    includeModules: true

webpack.config:

const slsw = require("serverless-webpack")
const nodeExternals = require("webpack-node-externals")
// const CopyPlugin = require("copy-webpack-plugin")

module.exports = {
  entry: slsw.lib.entries,
  target: 'node',
  // Generate sourcemaps for proper error messages
  devtool: 'source-map',
  // Since 'aws-sdk' is not compatible with webpack,
  // we exclude all node dependencies
  externals: [nodeExternals()],
  mode: slsw.lib.webpack.isLocal ? "development" : "production",
  optimization: {
    // We do not want to minimize our code.
    minimize: false
  },
  performance: {
    // Turn off size warnings for entry points
    hints: false
  },
  // node: false,
  // devtool: 'inline-cheap-module-source-map',
  // Run babel on all .js files and skip those in node_modules
  module: {
    rules: [
      {
        test: /\.js$/,
        include: __dirname,
        exclude: /node_modules/,
        use: [
          {
            loader: 'babel-loader',
            options: {
              presets: [
                [
                  '@babel/preset-env',
                  {
                    targets: { node: '12' },
                    useBuiltIns: 'usage',
                    corejs: 3,
                  },
                ],
              ],
            },
          },
        ],
      },
    ],
  },
  plugins: [
    // TODO
    // new CopyPlugin([
      // 'path/to/specific/file',
      // 'recursive/directory/**',
    // ]),
  ],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant