脚手架开发调试原理(Principle of scaffold development and commissioning)

使用npm link 的方式生成软链接,链接到当前开发目录

  • 在开发脚手架过程中通常会采用分包开发
  • 将需要分包的lib文件夹使用npm link的方式,在全局node_modules 下面添加一个指向开发目录的软连接
  • 在执行文件开发目录下通过 npm link lib 的方式添加一个指向全局node_modules的包
  • 它的执行过程是这样的
  • 操作系统解析主命令找到可执行文件cmd 或软连接,执行全局node_modules下的软连接或快捷方式
  • 全局node_modules下的软连接指向开发目录的可执行文件
  • 运行文件通过node内置的module模块中的path一层层向上查找需要的包,找到lib包发现是软连接或快捷方式
  • 其指向的是全局node_modules下的lib包,然后继续查找通过全局node_modules找到开发目录的lib包
————————

Use NPM link to generate soft links and link to the current development directory

  • Subcontracting development is usually used in the development of scaffolding
  • The Lib folder to be subcontracted uses NPM link in the global node_ Add a soft link to the development directory under modules
  • Add a node pointing to the global node through NPM link Lib in the development directory of the execution file_ Modules package
  • Its execution process is like this
  • The operating system parses the main command, finds the executable file CMD or soft connection, and executes the global node_ Soft connection or shortcut under modules
  • Global node_ The soft link under modules points to the executable file of the development directory
  • Run the file to find the required package layer by layer through the path in the module module built in node. Find the Lib package and find that it is a soft connection or shortcut
  • It points to the global node_ Lib package under modules, and then continue to find the global node_ Modules find the Lib package of the development directory