Docz: 类型错误:n 不是函数

创建于 2018-12-24  ·  33评论  ·  资料来源: doczjs/docz

错误报告

文档:0.12.17 & 0.13.5

再现
npx docz 开发

/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@docz-core/dist/index.js:5227
        n({
        ^

TypeError: n is not a function
    at parseHtml (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@docz-core/dist/index.js:5227:9)
    at template (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@docz-core/dist/index.js:5365:21)
    at MiniHtmlWebpackPlugin.plugin (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@mini-html-webpack-plugin/index.js:17:33)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@tapable/lib/HookCodeFactory.js:32:10), <anonymous>:12:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@tapable/lib/Hook.js:154:20)
    at Compiler.emitAssets (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@webpack/lib/Compiler.js:363:19)
    at onCompiled (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@webpack/lib/Watching.js:50:19)
    at hooks.afterCompile.callAsync.err (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@webpack/lib/Compiler.js:552:14)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@tapable/lib/Hook.js:154:20)
    at compilation.seal.err (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@webpack/lib/Compiler.js:549:30)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@tapable/lib/HookCodeFactory.js:32:10), <anonymous>:9:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@tapable/lib/Hook.js:154:20)
    at hooks.optimizeAssets.callAsync.err (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@webpack/lib/Compilation.js:1323:35)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@tapable/lib/HookCodeFactory.js:32:10), <anonymous>:9:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/puwei/Dev/test/test_lib/test-library/node_modules/[email protected]@tapable/lib/Hook.js:154:20)

我流动了缩小的代码,发现e是字符串 'null',而不是 null。

getHtmlFilepath = e =>
    e ? path.resolve(root$1, e) : fromTemplates("index.tpl.html"),
htmlTemplate = async e =>
    compiled(getHtmlFilepath(e), { minimize: !1, escape: !1 }),

所以它遵守了一个错误:

 { Error: ENOENT: no such file or directory, open '/Users/puwei/Dev/test/test_lib/test-library/null'
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/puwei/Dev/test/test_lib/test-library/null' }

最有用的评论

现在 docz-core 已更新为最新版本,谢谢@simonepri 🙏修复了错误,我正在发布一些修复此错误的新版本:)

所有33条评论

坏的:
image
好:一个旧的回购(昨天)
image

我有同样的问题。 正如@clock157所说,当indexHtml选项设置为默认值时,html 路径设置为字符串'null'

同样的问题,如何解决?

@aleen42现在,在doczrc.js手动设置默认值对我有用

手动设置null时遇到另一个问题,我应该设置什么值?

Module not found: Can't resolve 'null' in 'xxx/.docz/app'

尝试设置空字符串 '' ? @aleen42

undefined对我有用。

好像不行,等官方解决吧。

将 indexHtml 设置为undefined有效,但它导致(至少对我而言)另一个错误:找不到模块:无法解析 'docz-theme-default' in...

我刚刚尝试将 Docz 降级到旧版本,当我放弃时,错误一直回到 0.12.5。 错误可能与 Docz 的一些孩子有关吗?

@jedrichards显然是由于子依赖,因为当问题出现时,今天没有任何最近的提交。

@aleen42我也这么认为。 顺便说一句,如果我rm -rf node_modules && rm yarn.lock && yarn install ,我的 Gatsby 构建也会损坏,所以我认为某处有一个糟糕的子部门。

@jedrichards如果您在rm -rf node_modules && rm yarn.lock && yarn install之前的版本控制中使用了yarn.lock将以前的版本与您当前的yarn.lock揭示出一些潜在的变化对象?

我正在确认一个问题,但我不小心使用 npm 从 0.12.15 更新到 0.13.5。 现在把它恢复回来也无济于事。 清理node_modulespackage-lock.jsonyarn-lock.json没有帮助。

遇到同样的问题。 全新安装,从未在项目中使用过docz

设置indexHtml的选项doczrc.jsundefined解决了这个问题对我来说:

// ./doczrc.js
module.exports = {
  indexHtml: undefined
}

但是,这会产生下一个问题:

Module not found: Can't resolve 'null' in '/Users/.../libs/msw/.docz/app'

除了''undefined作为indexHtml的值,这里没有任何区别。

向下滚动到0.12.2 (3 个月旧版本),未找到null模块的问题仍然存在。

有什么解决办法吗?

我正在尝试解决这个问题,我猜env-dot-prop的最新版本没有解析默认值,所以布尔值和空值没有解析😕我试图在本地重现错误以修复。

@pedronauck您如何看待https://github.com/pedronauck/docz/issues/463#issuecomment -441000459 以避免此类 semver 问题?

嗯,我认为这里的问题是我们没有测试来防止这种类型的错误,有时这些错误只会发生在 monorepo 之外的全新安装中。 因为我总是使用我们的 monorepo 中的示例进行手动测试,例如,这个错误并没有发生在里面。 我不知道,但我认为这是没有测试的代价,并且总是试图保持依赖关系常青开始编写测试(unitary 和 e2e)并将一些部分保留在我们的核心之外(例如使用 poi 作为打包器)...

@pedronauck抱歉这个问题!

[email protected]我介绍了一个错误的解析(值并不解析),我[email protected]

这里的要点是该修复程序还更改了禁用默认值解析的 get 行为。 我现在正在发布一个 1.1.2 版本,以恢复这个不需要的功能以避免任何其他麻烦。

我建议你更新到[email protected] ,它有更好的测试并且应该确实更稳定。

我怀疑它@simonepri ,我试图找到任何具有重大更改的更改日志,但我没有找到。 顺便说一句,我将get的默认值更改为使用条件( get('docz.native') || null )。 我现在正在测试一些金丝雀版本,并尽快发布补丁,感谢提示🙏

@pedronauck更改可以在这里找到

现在 docz-core 已更新为最新版本,谢谢@simonepri 🙏修复了错误,我正在发布一些修复此错误的新版本:)

谢谢!

已在v0.13.7

@pedronauck我已经[email protected]并发布[email protected]

[email protected]的新单元测试不应再次发生此类错误。
再次抱歉。

@pedronauck我认为应该被恢复。

其实我认为你可能引入了一个错误。
image
即使 getEnv 返回 false,这也始终为 true。

很棒的@simonepri ,感谢您的帮助,顺便说一句,您的包裹真的很有用,我喜欢它❤️

好妈妈,真的,你说得对😕

你能检查一下[email protected]解决了这个问题?
谢谢!

我更新到版本2.0.1 ,也在修复那个版本,对吗@simonepri

是的2.0.1是稳定的并经过测试。

对了,我现在正在恢复和释放🙏

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

ilyanoskov picture ilyanoskov  ·  3评论

capaj picture capaj  ·  3评论

w0wka91 picture w0wka91  ·  3评论

tsnolan23 picture tsnolan23  ·  3评论

bichotll picture bichotll  ·  3评论