Lets say im working on an app, MyApp, and I want to build an NPM module for it, MyModule. Right now I can think of two ways to develop it:
What I'd like is an easier workflow. One where I can simply save the file, refresh the page, and my changes are there. Is that possible? For example, I know in Gemfiles I can just link to another directory as the path. Pretty sure I can't do that with npm tho.
You're looking for the npm link
command , which is a two steps process:
npm link
from your MyModule
directory: this will create a global package symlinked to the MyModule
directory npm link MyModule
from your MyApp
directory: this will create a MyModule
folder in node_modules
, symlinked to the global symlink (and thus to the real location of MyModule
). 要添加到Paul的答案,您还可以通过在MyApp
目录中执行以下操作来执行上述操作的快捷方式:
npm link ../MyModule
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.