[英]NPM workspace and VSCode node_modules path
I am using npm workspaces with typescript as specified in this git README https://github.com/Quramy/npm-ts-workspaces-example I am using npm workspaces with typescript as specified in this git README https://github.com/Quramy/npm-ts-workspaces-example
When I do npm i
from the project root directory it installs all packages in root directory (node_modules).当我从项目根目录执行npm i
时,它会将所有包安装在根目录(node_modules)中。 It doesn't create node_modules
directory in each workspace.它不会在每个工作区中创建node_modules
目录。 Because of this, VSCode thinks 'module' is missing (Cannot find module 'abcde' or its corresponding type declarations)
, hence shows red under line on import line and doesn't show auto complete suggestion.因此,VSCode 认为缺少“模块” (Cannot find module 'abcde' or its corresponding type declarations)
,因此在导入行的行下显示红色并且不显示自动完成建议。
How can I make VSCode understand that packages are installed in root folder and use it for giving auto complete suggestion and remove red underlines under package import.如何让 VSCode 了解软件包安装在根文件夹中并使用它来提供自动完成建议并删除 package 导入下的红色下划线。
I had this issue when turning an existing project into a workspace of a larger project.将现有项目转换为更大项目的工作区时,我遇到了这个问题。 Here are the steps that worked for me:以下是对我有用的步骤:
package-lock.json
and node_modules/
from the subdirectory从子目录中删除package-lock.json
和node_modules/
I think step (2) was the key to making it work, but I don't know for sure.我认为步骤 (2) 是使其工作的关键,但我不确定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.