我想这样做,所以npm install也会安装这个包。Json的../somelocallib或者更重要的是它的依赖项。
"dependencies": {
"express": "*",
"../somelocallib": "*"
}
我想这样做,所以npm install也会安装这个包。Json的../somelocallib或者更重要的是它的依赖项。
"dependencies": {
"express": "*",
"../somelocallib": "*"
}
当前回答
这对我来说很有效:首先,确保npm目录有正确的用户
sudo chown -R myuser ~/.npm
sudo chown -R myuser /usr/local/lib/node_modules
那你就在你的包裹里。Json链接目录
"scripts": {
"preinstall": "npm ln mylib ../../path/to/mylib"
},
"dependencies": {
"mylib" : "*"
}
其他回答
实际上,从npm 2.0开始,现在已经支持本地路径了。
这对我来说很有效:首先,确保npm目录有正确的用户
sudo chown -R myuser ~/.npm
sudo chown -R myuser /usr/local/lib/node_modules
那你就在你的包裹里。Json链接目录
"scripts": {
"preinstall": "npm ln mylib ../../path/to/mylib"
},
"dependencies": {
"mylib" : "*"
}
现在可以在包中指定本地Node模块安装路径。直接json。从文档中可以看出:
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.
这对我很有用。
将以下内容放入包中。json文件
"scripts": {
"preinstall": "npm install ../my-own-module/"
}
用纱线可以这样做
纱线添加文件:../somelocallib