简体   繁体   English

npm 本地开发与生产 package 版本

[英]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.

相关问题 开发和生产期间的NPM版本 - NPM versions during development and production (可选)在开发环境中使用本地npm软件包 - Optionally use a local npm package in development environment `react-hover` npm软件包不在生产版本中,但在开发中运行良好 - `react-hover` npm package not in production build but working fine in development 网站在本地工作/不在Openshift上运行(将本地,全局npm软件包版本与服务器,全局npm软件包版本同步) - Site works locally / Not on Openshift (syncing local, global npm package versions with server, global npm package versions) NPM包本地VS全局范围 - NPM Package local VS global scope 开发和生产中的不同jQuery版本 - Different jQuery versions in development and production 我如何专门使用 NPM 本地依赖项进行本地开发,以及使用来自外部注册表的一个依赖项进行生产? - How do I specifically use an NPM local dependency for local development and one from an external registry for production? NPM生产开发上直播服务器 - NPM production and development on live server Python相当于node.js的npm链接使用本地开发版本的需求? - Python equivalent of node.js's npm link to use local development versions of requirements? NPM package.json依赖项及其在本地和全局中的可执行文件 - NPM package.json dependencies and their executables in local vs global
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM