javascript - __webpack_require__(...).context is not a function - Stack Overflow

I'm gettingindex.js:978 TypeError: __webpack_require__(...).context is not a functionat eval (in

I'm getting

index.js:978 TypeError: __webpack_require__(...).context is not a function
at eval (index.vue:20)
at Object.dqAR (pages-investment-pages-home-index.js:348)
at __webpack_require__ (index.js:854)
at fn (index.js:151)
at eval (null:1)
at Module.Hi1e (pages-investment-pages-home-index.js:177)
at __webpack_require__ (index.js:854)
at fn (index.js:151)
at eval (null:1)
at Module.bE2I (pages-investment-pages-home-index.js:320)

here is my code

const path = './'
require.context(path,false,/\.js$/)

it looks like the arguments of require.context can't be a varible. because when i used like this it works fine:

require.context('./',false,/\.js$/)

i am confuse about it.

is that because of this function is belong to webpack and it's running before the pile?

thanks for ur answer.

I'm getting

index.js:978 TypeError: __webpack_require__(...).context is not a function
at eval (index.vue:20)
at Object.dqAR (pages-investment-pages-home-index.js:348)
at __webpack_require__ (index.js:854)
at fn (index.js:151)
at eval (null:1)
at Module.Hi1e (pages-investment-pages-home-index.js:177)
at __webpack_require__ (index.js:854)
at fn (index.js:151)
at eval (null:1)
at Module.bE2I (pages-investment-pages-home-index.js:320)

here is my code

const path = './'
require.context(path,false,/\.js$/)

it looks like the arguments of require.context can't be a varible. because when i used like this it works fine:

require.context('./',false,/\.js$/)

i am confuse about it.

is that because of this function is belong to webpack and it's running before the pile?

thanks for ur answer.

Share Improve this question asked Dec 31, 2021 at 9:46 DouDou 981 silver badge6 bronze badges 1
  • See also different solution at stackoverflow./a/74572172/12534 – Christian Davén Commented Mar 9, 2023 at 7:50
Add a ment  | 

1 Answer 1

Reset to default 9

The arguments passed to require.context must be literals! (look at warning in the link)

In the images below the right side is the generated webpack from left side:

Using literals generates valid __webpack_require__:

Using variables generated invalid __webpack_require__:

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743979411a4538664.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信