-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[V5] next.js 使用报错:Global CSS cannot be imported from within node_modules. #3951
Comments
已复现,原因是这个:https://nextjs.org/docs/messages/css-npm |
@awmleer 请问这个问题上面提到需要组件库对CSS引入方式做调整。 这一块目前支持了吗?因为今天试了下,这个报错还是存在 |
@MrZhangFengfeng 你按照这篇文档里描述的方式配置了么:https://mobile.ant.design/guide/ssr |
@awmleer 不使用ssr也需要参照使用next.js的配置吗? |
@frljx 应该是的 |
解决了吗 ?我看报错依然存在 NextJS v 13.4.7 |
您好,我已收到你的邮件,我会尽快回复。谢谢。
|
当使用 next-compose-plugins 这个 时 const withPlugins = require('next-compose-plugins')
const withAntdLess = require('next-plugin-antd-less')
const pluginAntdLess = withAntdLess({
modifyVars: { '@primary-color': '#FE8635' },
})
const withTM = require('next-transpile-modules')([
'antd-mobile',
]);
module.exports = withPlugins([pluginAntdLess,withTM] ,{
// 你的配置
}) 而不是 module.exports = withTM({
// 你项目中其他的 Next.js 配置
}); |
在antd-mobile的文档里有解决方法:https://mobile.ant.design/zh/guide/ssr |
您好,我已收到你的邮件,我会尽快回复。谢谢。
|
请求帮助如何在next中使用antd mobile v5
根据文档步骤
在页面中引入
会导致报错
Global CSS cannot be imported from within node_modules.
同时
import {Button} from 'antd-mobile/es/components/button'
vs code 提示模块 ""antd-mobile/es/components/button"" 没有导出的成员 "Button"。你是想改用 "import Button from "antd-mobile/es/components/button"" 吗?
导入方式修改为
import Button from 'antd-mobile/es/components/button'
后就没有vs code 的报错了请问是需要配置
.babelrc
跟next.config.js
吗?配置以下文件,仍然出现
Global CSS cannot be imported from within node_modules.
与一个新的错误Cannot use import statement outside a module
复现仓库:https://github.com/TinsFox/react-app-antd-v5
The text was updated successfully, but these errors were encountered: