reactjs - 使用 create-react-app 和 Yarn 2.0 进行本地开发
问题描述
我很难设置一个 React 项目来使用我的 Node 模块的本地版本。我像往常一样使用
npx create-react-app my-app
我使用切换到 Yarn 2.0
yarn set version berry
我还将 Yarn 配置为使用node-modules
而不是 PnP。
我尝试使用链接我的依赖项
yarn link ../../my-cool-module
我在 App.js 中使用我的模块添加了一些代码,但是当我运行时yarn build
出现类似错误
./src/App.js
Cannot find module: 'my-cool-module'. Make sure this package is installed.
package.json 片段由更新yarn link
"resolutions": {
"my-cool-module": "portal:/path/to/the/my-cool-module"
}
我在网上看到很多人称赞这个新的 Shiny yarn 2.0 协议portal
,但是有没有人设法让它工作?!
解决方案
推荐阅读
- sql - Oracle SQL 查询在人员之间平均分配任务
- python - PyCharm 无法安装软件包
- typescript - 如何使用打字稿中的tensorflow js(tfjs)?
- json - kotlin 中的 Spinner、键值和 json
- solr - 如何使用 edismax 解析器在 solr 中进行条件提升
- sql - SQL Server:日期时间存储为具有奇怪值的 Int
- python - ValueError:要解压的值太多(预期为 3)-WebServer
- c++ - c++,JSON,获取数组中的对象成员
- python - 通过函数陈述条件的正确方法
- angular - PrimeNG 表在值更改后保存选定的页面