干净安装最新版本的 docz。 当我运行 docz dev 时,我得到:
./node_modules/docz/dist/index.m.js 473:30
Module parse failed: Unexpected token (473:30)
You may need an appropriate loader to handle this file type.
| async function loadFromImports(path) {
| // tslint:disable-next-line
> const { imports } = await import('~imports');
| const { default: Component$$1, getInitialData } = await imports[path]();
| const ExportedComponent = props => (createElement(AsyncComponent, Object.assign({}, props, { as: Component$$1 || 'div', getInitialData: getInitialData })));
@ ./node_modules/docz-theme-default/dist/index.m.js 39:0-72 243:12-16 374:35-39 466:34-45 467:8-12 511:25-29 552:50-54 640:16-27 643:41-45 942:20-24 1024:28-39 1098:16-27 1490:33-44 1601:16-27 1872:16-27 1935:29-40 2029:45-56 2040:25-36 2041:8-18 2073:16-21
@ ./.docz/app/root.jsx
@ ./.docz/app/index.jsx
@ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@babel/polyfill/lib/index.js ./.docz/app/index.jsx
我无法共享项目链接。
我检查 webpack 别名:
modifyBundlerConfig : (config) => {
console.log(config.resolve.alias);
return config;
}),
并且~imports
存在。
提前致谢
肯定会遇到同样的问题。 我可以分享我的项目。
我可以告诉你@pedronauck问题出在哪里:
不兼容在于[email protected]
-> [email protected]
的升级。
diff --git b/package-lock.json a/package-lock.json
index f0a5074..054340d 100644
--- b/package-lock.json
+++ a/package-lock.json
@@ -1787,10 +1787,13 @@
"dev": true
},
"acorn-dynamic-import": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz",
- "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==",
- "dev": true
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz",
+ "integrity": "sha512-zVWV8Z8lislJoOKKqdNMOB+s6+XV5WERty8MnKBeFgwA+19XJjJHs2RP5dzM57FftIs+jQnRToLiWazKr6sSWg==",
+ "dev": true,
+ "requires": {
+ "acorn": "^5.0.0"
+ }
},
"acorn-globals": {
"version": "4.3.0",
@@ -16621,17 +16624,17 @@
"dev": true
},
"webpack": {
- "version": "4.29.0",
- "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.29.0.tgz",
- "integrity": "sha512-pxdGG0keDBtamE1mNvT5zyBdx+7wkh6mh7uzMOo/uRQ/fhsdj5FXkh/j5mapzs060forql1oXqXN9HJGju+y7w==",
+ "version": "4.28.4",
+ "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.28.4.tgz",
+ "integrity": "sha512-NxjD61WsK/a3JIdwWjtIpimmvE6UrRi3yG54/74Hk9rwNj5FPkA4DJCf1z4ByDWLkvZhTZE+P3C/eh6UD5lDcw==",
"dev": true,
"requires": {
"@webassemblyjs/ast": "1.7.11",
"@webassemblyjs/helper-module-context": "1.7.11",
"@webassemblyjs/wasm-edit": "1.7.11",
"@webassemblyjs/wasm-parser": "1.7.11",
- "acorn": "^6.0.5",
- "acorn-dynamic-import": "^4.0.0",
+ "acorn": "^5.6.2",
+ "acorn-dynamic-import": "^3.0.0",
"ajv": "^6.1.0",
"ajv-keywords": "^3.1.0",
"chrome-trace-event": "^1.0.0",
@@ -16652,12 +16655,6 @@
"webpack-sources": "^1.3.0"
},
"dependencies": {
- "acorn": {
- "version": "6.0.5",
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.5.tgz",
- "integrity": "sha512-i33Zgp3XWtmZBMNvCr4azvOFeWVw1Rk6p3hfi3LUDvIFraOMywb1kAtrbi+med14m4Xfpqm3zRZMT+c0FNE7kg==",
- "dev": true
- },
"schema-utils": {
"version": "0.4.7",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.7.tgz",
如果有人坚持这一点,并遵循@dfee的提示,这似乎可以解决这个问题:
npm i -D [email protected]
谢谢@dfee ,这已经在将要发布的v0.14
上修复了。 我可以关闭这个问题吗?
npm install docz@latest现在默认为 0.13.7,请在最新版本中发布 0.14 以解决此问题。
fyi pedro 目前生病了,几天后会回复这个问题(我不代表他说话,只是转发信息)
fyi pedro 目前生病了,几天后会回复这个问题(我不代表他说话,只是转发信息)
如果有人坚持这一点,并遵循@dfee的提示,这似乎可以解决这个问题:
npm i -D [email protected]
谢谢,等待 v0.14
+1 在这里。
提到的技巧有效,但由于在我们的 CI 上失败了,将这个 hack 作为构建中的一个步骤真的很痛苦:(
v0.14 什么时候发布?
嗨@dfee和这里的每个人都有 webpack 问题
原来 webpack 4.29 有一些我不完全理解的古怪 npm 依赖问题。 刚刚在我正在帮助的一个无关项目中看到了这一点: https :
一团糟。 尽量使用纱线。
我们正面临这个问题:(
同样在这里
同样在这里。
作为记录:我实际上没有在我的项目中安装 Webpack。
@bichotll我认为他们的意思是您需要更新node_modules/docz-core
内的版本。 我一直在用这个cd node_modules/docz-core && npm i -D [email protected] && cd .. && cd ..
@mattietea哦! 感谢您的提醒! 👍
npm i -D [email protected]
。 但对于新手来说,这可能会让人感到困惑。 期待尽快发布 0.14。
非常感谢你的帮助。 看起来一切都适用于 Yarn,问题只出现在 NPM 和 WebPack 问题上。 我有一个空项目,仅用package.json
进行测试,并使用来自@mattietea的说明,我设法使 docz 工作,但现在我在浏览器中出现错误。 我想我会在[email protected]__更新之前使用 Yarn。
@timbergus我有同样的问题,如果你锁定[email protected]
就可以解决。 我围绕这个打开了一个问题:
https://github.com/bublejs/buble/issues/189
[email protected]
技巧对我不起作用。 就我而言,导入的 CSS 文件出现一堆错误。
哦,很抱歉我是个菜鸟..这是我第一个小时使用 docz :)
我只需要docz-plugin-css
一切都很好,很抱歉造成混乱!
Docz 正在使用[email protected]
,此错误在此版本中一直显示?
刚刚在全新安装时遇到了同样的问题。 对我来说,通过使用 Yarn 再次创建项目解决了这个问题。 npm 安装失败,错误类似于@ohardy发布的错误。
重现错误:
npm init -y
npm install -D docz<strong i="8">@next</strong> docz-theme-default<strong i="9">@next</strong>
# Add scripts to the package.json from the documentation.
npm run docz:dev
复制成功:
npm init -y
yarn add docz<strong i="13">@next</strong> docz-theme-default<strong i="14">@next</strong> --dev
# Add scripts to the package.json from the documentation.
yarn run docz:dev
完整错误:
ERROR Failed to compile with 2 errors 1:39:50 PM
error in ./node_modules/docz/dist/index.esm.js
Module parse failed: Unexpected token (15:38)
You may need an appropriate loader to handle this file type.
| import { MDXProvider } from '@mdx-js/tag';
|
> const BasePlayground = loadable(() => import('./chunk.esm2.js'));
| const Playground = props => typeof window !== 'undefined' ? (createElement(Suspense, { fallback: null },
| createElement(BasePlayground, Object.assign({}, props)))) : null;
@ ./.docz/app/root.jsx 9:0-59 16:2-15 18:19-23 25:25-31
@ ./.docz/app/index.jsx
@ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./.docz/app/index.jsx
error in ./node_modules/docz-theme-default/dist/index.esm.js
Module parse failed: Unexpected token (245:30)
You may need an appropriate loader to handle this file type.
| `;
|
> const CodeMirror = lazy(() => import('./chunk.esm2.js'));
| const getLanguage = (children) => {
| const defaultLanguage = 'jsx';
@ ./.docz/app/root.jsx 11:0-39 17:29-34
@ ./.docz/app/index.jsx
@ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./.docz/app/index.jsx
版本:
希望这可能会以某种方式有所帮助。
@pedronauck回答您的问题,我在 rc7 上使用 webpack 4.29.6 仍然遇到此问题。 遗憾的是,我的组织必须支持 Npm,否则上述解决方法确实有效。
关闭支持#704,答案就在那里。
最有用的评论
如果有人坚持这一点,并遵循@dfee的提示,这似乎可以解决这个问题:
npm i -D [email protected]