npm install package in absolute path (Locally and package.json)

强颜欢笑 提交于 2019-12-08 13:19:17

问题


First of all, huge apology for naive question and if this sounds duplicate.

I wish to install a package, for example material-ui, as an external dependency under a different path like ./node_module/my-material-ui. The problem is I don't seem to find any option to tell npm to do this other than --prefix option which actually doesn't help because it installs the package under ./node_module/my-material-ui/node_modules/material-ui. Infact, this makes sense since it prefixes the installation path. I searched around but didn't immediately find a solution.

Now as a following question, instead of individually (and locally) installing the aforementioned package using npm install ..., you wish to specify where the package has to be installed in package.json. In other words, how one can achieve the above goal by specifying that inside package.json.

Thanks in advance for your help and recommendations!


回答1:


The migration guide covers this scenario.

yarn add material-ui@latest
yarn add material-ui-next@npm:material-ui@next

then

import FlatButton from 'material-ui/FlatButton'; // v0.x
import Button from 'material-ui-next/Button'; // v1.x


来源:https://stackoverflow.com/questions/47947521/npm-install-package-in-absolute-path-locally-and-package-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!