简体   繁体   English

将node_modules文件夹放置在单独的文件夹中

[英]place node_modules folder in separate folder

we are using create-react-app for building react application. 我们正在使用create-react-app构建反应应用程序。 All the dependencies will be installed in current project folder under node_modules. 所有依赖项都将安装在node_modules下的当前项目文件夹中。 But the requirement is shouldn't to be install it in current project folder. 但是要求不应该将其安装在当前项目文件夹中。 It should be in some other location and our application should point that location for libraries. 它应该在其他位置,我们的应用程序应该为库指向该位置。 so please help me to implement this functionality. 因此,请帮助我实现此功能。

Thanks, Narsi p 谢谢,Narsi p

Global Setting 全局设置

Set the prefix location of node_modules 设置node_modules的前缀位置

npm config set prefix "$(pwd)/custom/location/node/modules"

Here ${pwd} is the current working directory ${pwd}是当前的工作目录

Project Level Setting 项目级别设定

npm install --prefix /custom/node_modules/location

OR 要么

NPM_CONFIG_PREFIX=/custom/node_modules/location npm install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM