如何将npm安装到指定目录? [英] How to npm install to a specified directory?

查看:674
本文介绍了如何将npm安装到指定目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行npm install <package>时是否可以指定目标目录?

Is it possible to specify a target directory when running npm install <package>?

推荐答案

您可以使用--prefix选项:

mkdir -p ./install/here/node_modules
npm install --prefix ./install/here <package>

该软件包将安装在./install/here/node_modules中.之所以需要mkdir,是因为npm否则可能会选择层次结构中较高位置的现有node_modules目录. (请参阅文件夹上的npm文档.)

The package(s) will then be installed in ./install/here/node_modules. The mkdir is needed since npm might otherwise choose an already existing node_modules directory higher up in the hierarchy. (See npm documentation on folders.)

这篇关于如何将npm安装到指定目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆