Skip to content

Missing Dependency errors are a bit cryptic #161

Closed

Description

@DrewML

Expected Behaviour

When missing a dependency needed to bundle up an action, a clear error will inform a user that they're missing a dependency when running aio app deploy

Actual Behaviour

Missing dependencies (in my case, a peer dependency, but will happen with any missing dep) leads to errors that aren't straight-forward for those not intimately familiar with webpack and npm:

> Build actions
✖ Build actions
Error: action build failed, webpack compilation errors:
./node_modules/graphql-tag/lib/graphql-tag.umd.js
Module not found: Error: Can't resolve 'graphql/language/parser' in '/Users/andrewlevine/aio-test/node_modules/graphql-tag/lib'
resolve 'graphql/language/parser' in '/Users/andrewlevine/aio-test/node_modules/graphql-tag/lib'
  Parsed request is a module
  using description file: /Users/andrewlevine/aio-test/node_modules/graphql-tag/package.json (relative path: ./lib)
    resolve as module
      /Users/andrewlevine/aio-test/node_modules/graphql-tag/lib/node_modules doesn't exist or is not a directory
      /Users/andrewlevine/aio-test/node_modules/graphql-tag/node_modules doesn't exist or is not a directory
      /Users/andrewlevine/aio-test/node_modules/node_modules doesn't exist or is not a directory
      /Users/andrewlevine/node_modules doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /Users/andrewlevine/aio-test/node_modules
        using description file: /Users/andrewlevine/aio-test/package.json (relative path: ./node_modules)
          using description file: /Users/andrewlevine/aio-test/package.json (relative path: ./node_modules/graphql/language/parser)
            no extension
              /Users/andrewlevine/aio-test/node_modules/graphql/language/parser doesn't exist
            .js
              /Users/andrewlevine/aio-test/node_modules/graphql/language/parser.js doesn't exist
            as directory
              /Users/andrewlevine/aio-test/node_modules/graphql/language/parser doesn't exist
[/Users/andrewlevine/aio-test/node_modules/graphql-tag/lib/node_modules]
[/Users/andrewlevine/aio-test/node_modules/graphql-tag/node_modules]
[/Users/andrewlevine/aio-test/node_modules/node_modules]
[/Users/andrewlevine/node_modules]
[/Users/node_modules]
[/node_modules]
[/Users/andrewlevine/aio-test/node_modules/graphql/language/parser]
[/Users/andrewlevine/aio-test/node_modules/graphql/language/parser.js]
 @ ./node_modules/graphql-tag/lib/graphql-tag.umd.js 7:13-47
 @ ./actions/graphql/index.js
 @ multi ./actions/graphql/index.js
    at compiler.run (~/.nvm/versions/node/v10.16.2/lib/node_modules/@adobe/aio-cli/node_modules/@adobe/aio-app-scripts/scripts/build.actions.js:98:41)
    at finalCallback (~/.nvm/versions/node/v10.16.2/lib/node_modules/@adobe/aio-cli/node_modules/webpack/lib/Compiler.js:257:39)
    at hooks.done.callAsync.err (~/.nvm/versions/node/v10.16.2/lib/node_modules/@adobe/aio-cli/node_modules/webpack/lib/Compiler.js:273:13)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/andrewlevine/.nvm/versions/node/v10.16.2/lib/node_modules/@adobe/aio-cli/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (~/.nvm/versions/node/v10.16.2/lib/node_modules/@adobe/aio-cli/node_modules/tapable/lib/Hook.js:154:20)
    at onCompiled (~/.nvm/versions/node/v10.16.2/lib/node_modules/@adobe/aio-cli/node_modules/webpack/lib/Compiler.js:271:21)
    at hooks.afterCompile.callAsync.err (~/.nvm/versions/node/v10.16.2/lib/node_modules/@adobe/aio-cli/node_modules/webpack/lib/Compiler.js:681:15)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/andrewlevine/.nvm/versions/node/v10.16.2/lib/node_modules/@adobe/aio-cli/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (~/.nvm/versions/node/v10.16.2/lib/node_modules/@adobe/aio-cli/node_modules/tapable/lib/Hook.js:154:20)
    at compilation.seal.err (~/.nvm/versions/node/v10.16.2/lib/node_modules/@adobe/aio-cli/node_modules/webpack/lib/Compiler.js:678:31)

Because this is a node-based application, I think developers will expect to see the typical "module not found" message you'd get from node without bundling.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

  1. Create a new I/O Application with an action
  2. Run npm install graphql-tag, and require('graphql-tag') in an action
  3. Run aio app deploy

Notes

npm version 7 plans to auto-install peerDependencies (again), which would make this less of an issue for peerDependencies, but still a problem for direct dependencies.

Platform and Version

Sample Code that illustrates the problem

Logs taken while reproducing problem

Activity

  1. changed the title [-]Peer Dependency errors are a bit cryptic[/-] [+]Missing Dependency errors are a bit cryptic[/+] on Feb 18, 2020
  2. shazron commented on Feb 20, 2020

    @shazron
    Contributor

    I think running the linter on the code could help, with the no-extraneous-require rule only: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-extraneous-require.md

    We could run this before a deploy.

  3. shazron commented on Apr 22, 2020

    @shazron
    Contributor

    use our eslint config: https://github.com/adobe/eslint-config-aio-lib-config it has the latest extraneous requires rule added.

    update: this has been added to the plugin itself. But any generated actions need to have this linter added to the generated project.

  4. removed their assignment
    on Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is neededquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions