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

Serverless: WARNING: Could not determine version of module xxxxx #805

Closed
axelblomberg opened this issue Apr 28, 2021 · 13 comments · Fixed by #1084
Closed

Serverless: WARNING: Could not determine version of module xxxxx #805

axelblomberg opened this issue Apr 28, 2021 · 13 comments · Fixed by #1084
Milestone

Comments

@axelblomberg
Copy link

This is a Bug Report

Description

Error example in detail
Serverless: Invoke webpack:package
Serverless: WARNING: Could not determine version of module arrify

Hi. We have an issue where our root hoisted dependencies (using Lerna) cannot be resolved correctly when we bundle and webpack:package runs. This is causing the bundled package.json file to include referenced version as an empty string, see below.

"dependencies": {
"arrify": "",
}

The general issue with this is that dependencies are automatically resolved to latest version which can cause issues if there are breaking changes and so on.

I noticed that there were a version published 8 hours ago by @j0k3r where this functionality was included;

image

However, this did not seem to do the trick. Anyone with similar issues using monorepo, serverless and serverless-webpack?

Similar or dependent issue(s):

Additional Data

  • Serverless-Webpack Version you're using: 5.4.2
  • Webpack version you're using: 4.16.2
  • Serverless Framework Version you're using: 1.83.2
@j0k3r
Copy link
Member

j0k3r commented Apr 28, 2021

Could you share your serverless configuration and packages.json?

@axelblomberg
Copy link
Author

axelblomberg commented Apr 28, 2021

I'll enclose the important stuff. Everything that is not explicitly versioned inside subpackages package.json gets the empty string.

Strucutre is;

root/
  node_modules (everything hoisted)
  package.json (root deps, lerna for example)
  serverless.webpack.config.js
  folder1/
     package1/
        package.json (package specific, gets hoisted to root)
        serverless.yml
        src
     package2
        package.json
        serverless.yml
        src

Serverless config

 webpack:
    webpackConfig: ../../serverless.webpack.config.js
    includeModules:
       nodeModulesRelativeDir: ../../

serverless.webpack.config.js

// webpack.config.js
const slsw = require("serverless-webpack");

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: [
    /^[@a-z\-0-9]+$/
  ],
  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
  },
  resolve: {
    extensions: [
      '.js',
      '.json',
      '.ts',
      '.tsx'
    ]
  },
  // Run babel on all .js files and skip those in node_modules
  module: {
    rules: [
        {
          test: /\.tsx?$/,
          exclude: /node_modules/,
          use: [{
            loader: 'ts-loader',
            options: {
              transpileOnly: true
            }
          }],
        }
      ]
  }
};

@j0k3r
Copy link
Member

j0k3r commented Apr 28, 2021

I see you are using version 5.4.2, but what I merged isn't available in that release. It's on master actually and not yet part of a release. It'll be part of the upcoming 5.5.0.

@j0k3r j0k3r added the awaiting reply Awaiting for a reply from the OP label Apr 29, 2021
@axelblomberg
Copy link
Author

Ah ok! Missed that it wasn't included in that release. Reading the READme kinda gives the impression that it's a feature that's available for the latest version.

Do you have any other ideas? When do you expect to release 5.5.0?

@j0k3r
Copy link
Member

j0k3r commented Apr 29, 2021

In the coming days I think.
You can follow the milestone: https://github.com/serverless-heaven/serverless-webpack/milestone/35

@j0k3r j0k3r removed the awaiting reply Awaiting for a reply from the OP label Apr 29, 2021
@j0k3r j0k3r added this to the 5.5.0 milestone Apr 29, 2021
@axelblomberg
Copy link
Author

@j0k3r Any updates on the planned release day?

@j0k3r
Copy link
Member

j0k3r commented May 6, 2021

As soon as all PRs got merged.
I hope as soon as possible.

@j0k3r
Copy link
Member

j0k3r commented May 10, 2021

I've just released 5.5.0, can you give it a try?

@axelblomberg
Copy link
Author

Will have a look tomorrow morning!

@axelblomberg
Copy link
Author

It does not work unfortunately. Below is a description of the issue

  1. When running sls package in package A, it includes certain externals in node_modules.
  2. These certain packages are not explicitly stated in package.json (package A), but are included since they are dependencies of symlinked packages stated in package.json (package A) (the symlinking is done by lerna).
  3. Since they are not explicitly stated, they can't be matched to version, hence auto-set to latest version.
  4. Somehow, we need to get the tool to understand that these packages are infact installed with a set version in the root node_modules and that this should be interpreted, and not look like this (see image)

image

This fix looked like the perfect fit for our issue, but unfortunately nothing really changed. It seems to find the ref to root node_modules, but does not produce any different output.

@chaoyangnz
Copy link

chaoyangnz commented Jun 11, 2021

still have the issue in latest 5.5.1

@ypxing
Copy link
Contributor

ypxing commented Aug 30, 2021

Hi @axelblomberg I cannot reproduce your issue. Can you share your package.json (package specific, gets hoisted to root)?

Also the issue you reported is different from what #689 resolves.
The fix resolves issue WARNING: Could not check for peer dependencies

Your issue is WARNING: Could not determine version of module arrify

The package.json at root level and package level won't be changed by serverless-webpack. If they have empty version info in them, I reckon you need to fix them first.

@ypxing
Copy link
Contributor

ypxing commented Aug 30, 2021

Hi @chaoyangnz

Would you please share more information? Thanks

@j0k3r j0k3r linked a pull request Mar 29, 2022 that will close this issue
7 tasks
@j0k3r j0k3r modified the milestones: 5.5.0, 5.7.0 Mar 29, 2022
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

Successfully merging a pull request may close this issue.

4 participants