问题
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