[英]How to use a npm package for development without building it every time?
I am using npm link
to point to a local clone of the npm package.我正在使用
npm link
指向 npm package 的本地克隆。 In the package.json file of the npm package I have set the entrypoint to dist/index.js.在 npm 的 package.json 文件中 ZEFE90A8E604A7C840E88D03A6ZF6 的入口点设置为 7/D03A67F6 When I develop on the local version I don't want to rebuild the project every time.
当我在本地版本上开发时,我不想每次都重建项目。 How can I solve this problem?
我怎么解决这个问题?
Leave the package.json file entry point set to the dist/index.js
file.将package.json文件入口点设置为
dist/index.js
文件。
Then set a new scripts
option in the package.json file to run tsc <filename> -w
.然后在package.json文件中设置一个新的
scripts
选项来运行tsc <filename> -w
。 This will run the TypeScript Compile command with the watch flag .这将运行带有watch 标志的 TypeScript 编译命令。 This will recompile when files change in the directory.
当目录中的文件更改时,这将重新编译。
If you have a different flow that doesn't use tsc
directly or doesn't support a watch flag then see the link below that uses nodemon
.如果您有不直接使用
tsc
或不支持监视标志的不同流程,请参阅下面使用nodemon
的链接。
https://stackoverflow.com/a/48255950/5779200 https://stackoverflow.com/a/48255950/5779200
You can't avoid the build process so it's best to embrace it and understand the advantages of not changing the entry point between the deployment and the development.您无法避免构建过程,因此最好接受它并了解不更改部署和开发之间的入口点的优势。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.