Vue-cli: Uncaught TypeError: __webpack_require__(...).context is not a function

Created on 26 Apr 2019  ·  4Comments  ·  Source: vuejs/vue-cli

Version

3.6.0

Environment info

vue 2.6.0  @vue/cli-service   3.6.0

Steps to reproduce

js文件中使用 require.context (webpack提供)浏览器 出现__webpack_require__(...).context is not a function (require.context is not function ) 同样 require.ensure 也不可用

What is expected?

require.context 可用

What is actually happening?

require.context 不可用

needs reproduction

Most helpful comment

Seriously you are on an english-based community, you cannot speak in english, please? It may be useful for other devs reading you.

All 4 comments

请遵守 Issue Helper 的说明,请提供可以运行的复现

这个问题已解决 require-context
传递给 require.context 的参数必须是字面量(literal)!

Seriously you are on an english-based community, you cannot speak in english, please? It may be useful for other devs reading you.

What @itlangzi tried to say there is that the path parameter has to be a literal regex and can't be passed via variable.
You can read more about this in another issue here: https://github.com/webpack/webpack/issues/9300#issuecomment-524744609

Was this page helpful?
0 / 5 - 0 ratings