[英]IntelliJ: Unable to have multiple library roots
I feel like I'm in a bit of a unique situation as I can't find any documentation on how to make this interaction work.我觉得我处于一种独特的情况,因为我找不到任何关于如何使这种交互起作用的文档。 I have a repository that houses a Flask app that will contain code compiled through webpack from a different root, eg:
我有一个存储库,其中包含一个 Flask 应用程序,该应用程序将包含从不同根目录通过 webpack 编译的代码,例如:
REPO_ROOT/
|-- src/
|-- client/
|-- app/
|-- css/
|-- styles.css
|-- js/
|-- index.js
|-- index.html
|-- node_modules/
|-- package.json
|-- webpack.config.js
|-- server/
|-- .venv/
|-- app/
|-- static/
|-- templates/
|-- __init__.py
|-- MANIFEST.in
|-- setup.py
|-- tests/
|-- requirements.txt
|-- setup.cfg
... other meta files ...
The problem I'm running into: when I open this project, node_modules/
is correctly identified and I get proper completions in my client/
files, but server/
doesn't.我遇到的问题:当我打开这个项目时,
node_modules/
被正确识别,我在我的client/
文件中得到了正确的完成,但server/
没有。 After setting up the Python SDK to point at my virtual environment, I get completions in my server/
files, but it stops client/
from working!将 Python SDK 设置为指向我的虚拟环境后,我在
server/
文件中得到了完成,但它阻止了client/
工作! Then, it incorrectly marks src/
as the library root in the Project view.然后,它错误地将
src/
标记为项目视图中的库根。
Question: how do I set up IntelliJ to identify both .venv
and node_modules
to autocomplete from?问题:如何设置 IntelliJ 以识别要自动完成的
.venv
和node_modules
? When I run install on package.json
, it correctly identifies the path where it's at, but still doesn't work.当我在
package.json
上运行 install 时,它正确识别了它所在的路径,但仍然不起作用。
IntelliJ Ultimate 2019.2.1 IntelliJ Ultimate 2019.2.1
NodeJS & Python plugins NodeJS 和 Python 插件
Some additional things I've tried - deleting the SDK in the plugin, deleting node_modules/
and .venv/
, clearing the IntelliJ cache, restarting, recreating the libraries through the UI, and still getting the same result.我尝试过的一些其他操作 - 删除插件中的 SDK,删除
node_modules/
和.venv/
,清除 IntelliJ 缓存,重新启动,通过 UI 重新创建库,仍然得到相同的结果。 As soon as I set the Python SDK, it breaks node_modules/
from being identified as a library root .一旦我设置了 Python SDK,它就会将
node_modules/
识别为库 root 。
I've been experimenting with this and have come to the conclusion: when installing the flask app into the virtual environment SDK loaded by IntelliJ, it's unable to nest the other library root inside another.我一直在对此进行试验并得出结论:将 Flask 应用程序安装到 IntelliJ 加载的虚拟环境 SDK 中时,无法将其他库根目录嵌套在另一个库根目录中。
I resolved this by moving my js-specific meta files to the root alongside the py-specific meta files to end up looking like this:我通过将特定于 js 的元文件与特定于 py 的元文件一起移动到根目录来解决此问题,最终看起来像这样:
REPO_ROOT/
|-- .venv/
|-- node_modules/
|-- src/
|-- app/
|-- static/
|-- css/
|-- style.css
|-- js/
|-- index.js
|-- templates/
|-- index.html
|-- __init__.py
|-- tests/
|-- MANIFEST.in
|-- package.json
|-- requirements.txt
|-- setup.cfg
|-- setup.py
|-- webpack.config.js
This required extra config in webpack
to specify static/
as my context with an added dist/
as the output, but at this stage, it works.这需要
webpack
额外配置来指定static/
作为我的上下文并添加dist/
作为输出,但在这个阶段,它可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.