question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Critical dependency: the request of a dependency is an expression

See original GitHub issue

I’m trying to integrate the woocommerce virtual store module into my project and when I add the mutation “add_product_to_cart” I get the following error.

./~/ajv/lib/async.js
96:20-33 Critical dependency: the request of a dependency is an expression

The vue module:

<template>
  <div class="field has-addons">
    <p class="control is-expanded">
      <input class="input is-medium" type="text" placeholder="Código do produto" v-model="productCode">
    </p>
    <p class="control">
      <button  class="button is-info is-medium" @click="findProduct">
        Adicionar
      </button>
    </p>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        productCode: ''
      }
    },
    methods: {
      findProduct () {
        this.$store.commit('ADD_PRODUCT_TO_CART', this.productCode)
      }
    },
    name: 'find-product'
  }
</script>

The state/mutation module:

import * as types from '../mutation-types'
import Woo from 'woocommerce-api'

const wc = new Woo({
  url: 'http://wc-project.dev',
  consumerKey: 'ck_**',
  consumerSecret: 'cs_**',
  version: 'wc/v1',
  wpAPI: true
})

const state = {
  products: []
}

const mutations = {
  [types.ADD_PRODUCT_TO_CART] (state, payload) {
    console.log(payload)
    wc.get(`products/${payload}`, (err, data, res) => {
      if (err) return console.log(err)
      return console.log(res)
    })
  }
}

export default {
  state,
  mutations
}

Please ignore all this console.log, if i use only 1 console.log with console.log(payload) works fine.

  • Node version: v7.8.0
  • NPM version: 4.5.0
  • vue-cli version: 2.8.1
  • Operating System: Lubuntu (32bits)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
melquiccommented, May 15, 2017

Guys, I think I have found the problem. The npm modules I was using to call my external API wasn’t installed in the /app/package.json. I had installed them only in the root directory /package.json. They need to be there in order to be found during the building process. @rafa-acioly please, see if this is your scenario as well.

1reaction
rafa-aciolycommented, May 15, 2017

I’ll check and respond after the test, thank you! @melquic

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack - Critical dependency: the request of a dependency ...
Webpack - Critical dependency: the request of a dependency is an expression · Manually configure webpack to import the required libraries and ...
Read more >
Webpack Warning: Critical dependency: the request of a ...
[Edit: This seems to be related with WebPack in General, not with Angular] When activating this module in an Angular 12 project, this...
Read more >
the request of a dependency is an expression webpack - You ...
Webpack - Critical dependency: the request of a dependency is an expression ... When a library uses variables or expressions in a require...
Read more >
the request of a dependency is an expression - Get Help
When I use “require( )” inside a v-bind:src directive, I get “the warning Critical dependency: the request of a dependency is an expression” ......
Read more >
Integration with WebPack - Linkurious documentation
The optional dependencies used by Ogma is the xlsx library (to export in the XLSX ... Critical dependency: the request of a dependency...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found