[英]npm local development vs production package versions
I am trying to use my own package (let's call it database) in a project of mine.我正在尝试在我的项目中使用我自己的 package(我们称之为数据库)。 However since I am developing database next to the project myself, I don't want to push a version of database to the registry, then pull again on the project to have the latest version.
但是,由于我自己在项目旁边开发数据库,我不想将数据库版本推送到注册表,然后再次拉入项目以获得最新版本。 This is not a fast workflow given that both projects are in the same VS workspace.
这不是一个快速的工作流程,因为这两个项目都在同一个 VS 工作区中。
What I need is to reference the local project while development and when it is about production, then I need to actually use an external package.我需要的是在开发和生产时参考本地项目,然后我需要实际使用外部 package。 Is there a way that allows me to use a different package version of the same package depending on the environment?
有没有办法让我根据环境使用相同 package 的不同 package 版本?
I wish there was a NodeJS / Typescript IDE that just manages packages, building dependencies etc. for me.我希望有一个 NodeJS / Typescript IDE 只为我管理包、构建依赖项等。 Eg when I build my project, it would build database first.
例如,当我构建我的项目时,它会先构建数据库。 I know there are project references in typescript 3.0, however I am not sure how well they work with npm packages.
我知道 typescript 3.0 中有项目引用,但是我不确定它们与 npm 包的配合情况如何。
Thanks for any help.谢谢你的帮助。
Go to your package database
directory and run npm link
to create a global symlink, it would be like you have installed the database
globally. Go 到您的 package
database
目录并运行npm link
以创建全局符号链接,就像您已全局安装database
一样。
Go to your project to run npm link database
to use the local global package. Go到你的项目运行
npm link database
使用本地全局package。
You don't need to update your project's dependency when you update the database
since the global package is just a local symbol link to your database
.更新
database
时不需要更新项目的依赖项,因为全局 package 只是到database
的本地符号链接。
When you are ready to go production, run npm unlink database
to remove the local symbol link, and reinstall the package from the registry for the project, you need to publish it first of course.当你准备好 go 生产时,运行
npm unlink database
以删除本地符号链接,然后重新安装 package 从项目的注册表中发布它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.