如何解决Nextjs 使用纱线工作区生成嵌套的 node_modules 文件夹
我正在为我的 nextjs 和 react-native 应用程序使用一个 monorepo,使用 yarn 工作区。当我在我的根文件夹中运行 yarn install
时,yarn 会将所有模块安装在根 node_modules
文件夹中。但是当我在 nextjs 应用程序中运行 yarn dev
时,nextjs 会生成一个新的 node_modules
文件夹。我怎样才能防止这种情况?我需要改变什么才能让它工作?
我的 next.config.js
看起来像这样:
const withPlugins = require('next-compose-plugins')
const { dependencies } = require('./package.json')
const withTM = require('next-transpile-modules')(
Object.keys(dependencies || []).filter(dependency => dependency.startsWith('@project/'))
)
const config = {
future: {
webpack5: true
}
}
module.exports = withPlugins([
withTM
],config)
对于我的 react-native
应用程序,我在 projectRoot
中定义了一个 metro.config.js
路径,如下所示:
module.exports = {
projectRoot: path.resolve(__dirname,'../../'),}
nextjs 有没有类似的东西?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。