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

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

问题描述

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

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 install 到指定目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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