amis 版本由6.0.0升级到6.3.0 或是 6.4.1 启动报错

alen0pnh  于 5个月前  发布在  其他
关注(0)|答案(9)|浏览(56)
描述问题:

amis 版本由6.0.0升级到6.3.0 或是 6.4.1 启动报错、

截图或视频:

如何复现(请务必完整填写下面内容):
  1. 你是如何使用 amis 的?
    npm
  2. amis 版本是什么?请先在最新 beta 版本测试问题是否存在
    "amis": "6.4.1",
    "amis-core": "6.4.1",
    "amis-formula": "6.4.1",
    "amis-ui": "6.4.1",
    "amis-editor": "6.4.1",
    "amis-editor-core": "6.4.1",
  3. 粘贴有问题的完整 amis schema 代码:
code here...
  1. 操作步骤
    请简单描述一下复现的操作步骤...
7d7tgy0s

7d7tgy0s1#

删除依赖重装试试

4xy9mtcn

4xy9mtcn2#

我也是这个问题

e5njpo68

e5njpo683#

我把版本降下来,就好了

2uluyalo

2uluyalo4#

主要原因是因为编译器不支持可选链式操作符,也就是 ?. 的语法。
如果你使用的是webpack可以搜索以下关键词:webpack 可选链式操作符

关于webpack es6 的文章:https://webpack.docschina.org/api/module-methods/#es6-recommended
解决方案(仅供参考): https://webpack.docschina.org/loaders/babel-loader/

zf2sa74q

zf2sa74q5#

是umijs 3.5的脚手架 使用webpack5后 启动不报错 打开页面报错:
×
Error: The renderer with name "remark" has already exists, please try another name!
▼ 6 stack frames were expanded.
registerRenderer
./node_modules/amis-core/esm/factory.js:53
(anonymous function)
./node_modules/amis-core/esm/factory.js:33
__decorate
./node_modules/tslib/tslib.es6.mjs:58
(anonymous function)
./node_modules/amis-editor-core/node_modules/amis/esm/renderers/Remark.js:84
./node_modules/amis-editor-core/node_modules/amis/esm/renderers/Remark.js
./node_modules/amis-editor-core/node_modules/amis/esm/renderers/Remark.js:90
options.factory
webpack:/webpack/runtime/react refresh:6
▲ 6 stack frames were expanded.
webpack_require
./webpack/bootstrap:24
21 | var execOptions = { id: moduleId, module: module, factory: webpack_modules[moduleId], require: webpack_require };
22 | webpack_require.i.forEach(function(handler) { handler(execOptions); });
23 | module = execOptions.module;
24 | execOptions.factory.call(module.exports, module, module.exports, execOptions.require);
| ^ 25 | } catch(e) {
26 | module.error = e;
27 | throw e;
View compiled
▼ 3 stack frames were expanded.
fn
webpack:/webpack/runtime/hot module replacement:61
./node_modules/amis-editor-core/node_modules/amis/esm/renderers/Action.js
http://localhost:8000/umi.js:54725:68
options.factory
webpack:/webpack/runtime/react refresh:6
▲ 3 stack frames were expanded.
webpack_require
./webpack/bootstrap:24
21 | var execOptions = { id: moduleId, module: module, factory: webpack_modules[moduleId], require: webpack_require };
22 | webpack_require.i.forEach(function(handler) { handler(execOptions); });
23 | module = execOptions.module;
24 | execOptions.factory.call(module.exports, module, module.exports, execOptions.require);
| ^ 25 | } catch(e) {
26 | module.error = e;
27 | throw e;
View compiled
▼ 3 stack frames were expanded.
fn
webpack:/webpack/runtime/hot module replacement:61
./node_modules/amis-editor-core/node_modules/amis/esm/index.js
http://localhost:8000/umi.js:54281:78
options.factory
webpack:/webpack/runtime/react refresh:6
▲ 3 stack frames were expanded.
webpack_require
./webpack/bootstrap:24
21 | var execOptions = { id: moduleId, module: module, factory: webpack_modules[moduleId], require: webpack_require };
22 | webpack_require.i.forEach(function(handler) { handler(execOptions); });
23 | module = execOptions.module;
24 | execOptions.factory.call(module.exports, module, module.exports, execOptions.require);
| ^ 25 | } catch(e) {
26 | module.error = e;
27 | throw e;
View compiled
▼ 3 stack frames were expanded.
fn
webpack:/webpack/runtime/hot module replacement:61
./node_modules/amis-editor-core/esm/index.js
http://localhost:8000/umi.js:53221:62
options.factory
webpack:/webpack/runtime/react refresh:6
▲ 3 stack frames were expanded.
webpack_require
./webpack/bootstrap:24
21 | var execOptions = { id: moduleId, module: module, factory: webpack_modules[moduleId], require: webpack_require };
22 | webpack_require.i.forEach(function(handler) { handler(execOptions); });
23 | module = execOptions.module;
24 | execOptions.factory.call(module.exports, module, module.exports, execOptions.require);
| ^ 25 | } catch(e) {
26 | module.error = e;
27 | throw e;
View compiled
▼ 3 stack frames were expanded.
fn
webpack:/webpack/runtime/hot module replacement:61
./src/app.tsx
http://localhost:8000/umi.js:14966:74
options.factory
webpack:/webpack/runtime/react refresh:6
▲ 3 stack frames were expanded.
webpack_require
./webpack/bootstrap:24
21 | var execOptions = { id: moduleId, module: module, factory: webpack_modules[moduleId], require: webpack_require };
22 | webpack_require.i.forEach(function(handler) { handler(execOptions); });
23 | module = execOptions.module;
24 | execOptions.factory.call(module.exports, module, module.exports, execOptions.require);
| ^ 25 | } catch(e) {
26 | module.error = e;
27 | throw e;
View compiled
▼ 3 stack frames were expanded.
fn
webpack:/webpack/runtime/hot module replacement:61
./src/.umi/core/pluginRegister.ts
http://localhost:8000/umi.js:12788:66
options.factory
webpack:/webpack/runtime/react refresh:6
▲ 3 stack frames were expanded.
webpack_require
./webpack/bootstrap:24
21 | var execOptions = { id: moduleId, module: module, factory: webpack_modules[moduleId], require: webpack_require };
22 | webpack_require.i.forEach(function(handler) { handler(execOptions); });
23 | module = execOptions.module;
24 | execOptions.factory.call(module.exports, module, module.exports, execOptions.require);
| ^ 25 | } catch(e) {
26 | module.error = e;
27 | throw e;
View compiled
▼ 3 stack frames were expanded.
fn
webpack:/webpack/runtime/hot module replacement:61
./src/.umi/umi.ts
http://localhost:8000/umi.js:14836:78
options.factory
webpack:/webpack/runtime/react refresh:6
▲ 3 stack frames were expanded.
webpack_require
./webpack/bootstrap:24
21 | var execOptions = { id: moduleId, module: module, factory: webpack_modules[moduleId], require: webpack_require };
22 | webpack_require.i.forEach(function(handler) { handler(execOptions); });
23 | module = execOptions.module;
24 | execOptions.factory.call(module.exports, module, module.exports, execOptions.require);
| ^ 25 | } catch(e) {
26 | module.error = e;
27 | throw e;
View compiled
(anonymous function)
./webpack/startup:5
2 | // startup
3 | // Load entry module and return exports
4 | webpack_require("./node_modules/umi/node_modules/@umijs/preset-built-in/bundled/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js");
5 | var webpack_exports = webpack_require("./src/.umi/umi.ts");
6 |
View compiled
(anonymous function)
http://localhost:8000/umi.js:634931:12
This screen is visible only in development. It will not appear if the app crashes in production.
Open your browser’s developer console to further inspect this error. Click the 'X' or hit ESC to dismiss this message.

f1tvaqid

f1tvaqid6#

主要原因是因为编译器不支持可选链式操作符,也就是 ?. 的语法。 如果你使用的是webpack可以搜索以下关键词:webpack 可选链式操作符

关于webpack es6 的文章:https://webpack.docschina.org/api/module-methods/#es6-recommended 解决方案(仅供参考): https://webpack.docschina.org/loaders/babel-loader/

不是这个问题

smtd7mpg

smtd7mpg7#

我看官方修复了这个问题已经,我是那个pdf-js报错

thigvfpy

thigvfpy8#

我看官方修复了这个问题已经,我是那个pdf-js报错
pdf-js 错误 只要使用webpack5 就解决了,现在是启动不报错 ,访问页面的时候报错,提示:
Error: The renderer with name "remark" has already exists, please try another name!
▼ 6 stack frames were expanded.
registerRenderer
./node_modules/amis-core/esm/factory.js:53
(anonymous function)
./node_modules/amis-core/esm/factory.js:33
__decorate
./node_modules/tslib/tslib.js:106
(anonymous function)
./node_modules/amis-editor-core/node_modules/amis/lib/renderers/Remark.js:95
./node_modules/amis-editor-core/node_modules/amis/lib/renderers/Remark.js
./node_modules/amis-editor-core/node_modules/amis/lib/renderers/Remark.js:101
options.factory
webpack:/webpack/runtime/react refresh:6
也有其他小伙伴出现这种问题 就是不知道咋解决,看其他人配置:// 解决Remark 重复注册问题
config.merge({
resolve: {
conditionNames: ['require', 'node'],
},
}); 我也配了,但是问题没解决

nszi6y05

nszi6y059#

我的解决办法,瞎弄的
安装这个
npm install -D babel-loader @babel/core @babel/preset-env webpack

然后amis.config.js extensions里面增加 .mjs

alias 增加

'react/jsx-runtime': resolve('node_modules/react/jsx-runtime.js'),

相关问题