我在主项目中使用了一个库。库代码如下所示:/node_modules/@myCompany/all_components/src/Footer/components/Navlink/index.js
import React from 'react';
import styles from './style.module.scss';
export const NavLinks = ({ linksList }) => (
linksList
.map(({ url, title, id }) => (
<a
key={id}
className={styles.navLink}
href={url}>
{title}
</a>
))
);
现在在下一个app/pages/index.js中
import {NavLinks} from '@myCompany/all_components';
.....
export const Home = ({ data }) => {
return ()
};
.巴布勒克
{
"presets": ["next/babel"]
}
next.config.js
module.exports = {
webpack: (config) => {
config.resolve.extensions = ['.js', '.jsx'];
config.module.rules.push(
{test: /\.(js|jsx)$/, use: {
loader: "babel-loader",
options: {
presets: ['@babel/preset-env', '@babel/preset-react']
}
}}
);
return config;
}
}
但我收到了错误-
error - ./node_modules/@myCompany/all_componentss/src/Footer/components/NavLinks /style.module.scss
CSS Modules cannot be imported from within node_modules.
Read more: https://nextjs.org/docs/messages/css-modules-npm
Location: node_modules\@myCompany/all_components\src\Footer\components\NavLinks\index.js
[BABEL] Note: The code generator has deoptimised the styling of C:\Projects\service-page\node_modules\react-dom\cjs\react-dom.development.js as it exceeds the max of 500KB.
wait - compiling /_error (client and server)...
event - compiled client and server successfully in 47.8s (176 modules)
error - SyntaxError: Unexpected token 'export'
你能告诉我我在这里做错了什么吗?
1条答案
按热度按时间eh57zj3b1#
有一个解决方法。您可以使用next-css。它似乎是https://stackoverflow.com/a/55255918/19135131的副本
对你有帮助吗?