Local dependency in package.json

后端 未结 12 1217
被撕碎了的回忆
被撕碎了的回忆 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条回答
  •  逝去的感伤
    2020-11-22 17:37

    It is now possible to specify local Node module installation paths in your package.json directly. From the docs:

    Local Paths

    As of version 2.0.0 you can provide a path to a local directory that contains a package. Local paths can be saved using npm install -S or npm install --save, using any of these forms:

    ../foo/bar
    ~/foo/bar
    ./foo/bar
    /foo/bar
    

    in which case they will be normalized to a relative path and added to your package.json. For example:

    {
      "name": "baz",
      "dependencies": {
        "bar": "file:../foo/bar"
      }
    }
    

    This feature is helpful for local offline development and creating tests that require npm installing where you don't want to hit an external server, but should not be used when publishing packages to the public registry.

提交回复
热议问题