search

Home  >  Q&A  >  body text

node.js - linux对目录做软链后使用相对路径出错的问题

我对一个路径src做了一个软链,最终目录结构是这样的

--a
----src
--------config.js
----config.json
--b
----src -> ../a/src
----config.json

我在src目录下的config.js中有这么一句,var obj = requrie('../config.json');结果我在b目录下运行这个js文件,它引入的是文件是a/src/config.json,我想让其引用b/config.json,求解决方案。

阿神阿神2777 days ago563

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 11:55:02

    Soft links are generally not used in development. My understanding is that when deploying or publishing npm packages, the relative reference positions of soft links may not be saved, or there may be many pitfalls in processing.

    If you do this, it is best to explain the usage scenario. There may be other ways to solve your needs.

    reply
    0
  • Cancelreply