Local dependency in package.json

后端 未结 12 1287
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 16:42

I want to do something like this, so npm install also installs the package.json of ../somelocallib or more importantly its dependencie

12条回答
  •  -上瘾入骨i
    2020-11-22 17:45

    Curious.....at least on Windows (my npm is 3.something) I needed to do:

    "dependencies": {
     "body-parser": "^1.17.1",
     "module1": "../module1",
     "module2": "../module2",
    

    When I did an npm install ../module1 --save it resulted in absolute paths and not relative per the documentation.

    I messed around a little more and determined that ../xxx was sufficient.

    Specifically, I have the local node modules checked out to say d:\build\module1, d:\build\module2 and my node project (application) in d:\build\nodeApp.

    To 'install', I:

    d:\build\module1> rmdir "./node_modules" /q /s && npm install
    d:\build\module2> rmdir "./node_modules" /q /s && npm install
    d:\build\nodeApp> rmdir "./node_modules" /q /s && npm install
    

    module1's package.json has a dependency of "module2": "../module2"; module2 has no local dependency; nodeApp has dependencies "module1": "../module1" and "module2": "../module2".

    Not sure if this only works for me since all 3 folders (module1, module2 and nodeApp) sit on that same level.......

提交回复
热议问题