【问题标题】:Choosing node.js install from Conda environment in VSCode在 VSCode 中选择从 Conda 环境安装 node.js
【发布时间】:2020-10-23 06:13:33
【问题描述】:

我一直在使用 Conda,在 python 中,它的虚拟环境和 VSCode 没有任何问题。我决定在这个环境中也安装带有 Conda 的 node.js,这样我就可以为每个项目拥有一个完全隔离的环境,并为我的前端和后端安装自己的安装。

虽然在 python 中使用虚拟环境并没有给我带来任何问题,但我无法使用这种“虚拟 node.js”。问题与插件有关。任何人都知道我如何配置 VSCode 以便插件与此安装而不是全局 SO 安装一起使用?

我想从我的 SO 中卸载节点,以便能够使用 Conda 环境管理所有内容。

【问题讨论】:

    标签: node.js visual-studio-code anaconda conda miniconda


    【解决方案1】:

    Ubuntu 上,如果您首先将所有内容安装到 conda 环境中,然后从命令行启动 VS 代码,它就可以工作。

    例如,假设您有一个依赖于 python、node.js、git 和 truffle 的 VS Code 扩展,您可以执行以下操作:

    # create a conda environment with python & node
    conda create --name my_env python=3.9
    conda activate my_env
    
    # install yarn, which also installs node & npm
    conda install -c conda-forge yarn
    
    # install git
    conda install git
    
    # install truffle, which is an node.js package
    # install with -g flag, which means global, 
    #    but since we are in a conda environment
    #    it is global to that conda environment
    npm install -g truffle
    
    # verify that everything is isolated inside the conda environment
    which yarn
    which npm
    which node
    which git
    which truffle  # /home/.../miniconda3/envs/my_env/bin/truffle
    
    # Start VS Code from the command line
    # To open current folder, use '.'
    code .
    
    # Then, inside VS Code, you can install & work with the extension
    # and if you look in the output of commands, you can see it
    # picks up the proper commands
    

    我无法在 ma​​c 上使用这种方法。不知何故,它没有选择 conda 环境,我还没有找到一种方法让 VS Code 了解 conda 环境。

    【讨论】:

      猜你喜欢
      • 2022-01-02
      • 2019-01-04
      • 2021-06-22
      • 1970-01-01
      • 2020-10-21
      • 2019-08-18
      • 1970-01-01
      • 2021-10-20
      • 1970-01-01
      相关资源
      最近更新 更多