在postinstall上安装npm包

时间:2017-01-08 10:18:12

标签: node.js npm post-install npm-scripts

我有一个npm package,它具有对等依赖关系。我写了一个简短的postinstall脚本,它将提示用户安装对等依赖项,但它不起作用。

正如您将从下面的输出中看到的,看起来npm 正在下载程序包,但它不会出现在项目的任何位置,而不会出现在package.json上,而不会出现在{{1 }}

我正在运行ubuntu 16.04 btw

以下是安装npm软件包时会发生的情况:

node_modules

这是剧本:

➜  codeMentorTutorial npm i ../react-native-gradle-config

> react-native-gradle-config@2.0.0 postinstall /home/adam/apps/codeMentorTutorial/node_modules/react-native-gradle-config
> node lib/addScriptsToPackageJson && node lib/installPeerDependencies
...
This package has a peer dependency "replace", which is not installed in your project.
would u like to install it now? [Y/n]
installReplace
installReplace err, res null codeMentorTutorial@0.0.1 /home/adam/apps/codeMentorTutorial
└─┬ replace@0.3.0 
  ├── colors@0.5.1 
  ├─┬ minimatch@0.2.14 
  │ ├── lru-cache@2.7.3 
  │ └── sigmund@1.0.1 
  └─┬ nomnom@1.6.2 
    ├── colors@0.5.1 
    └── underscore@1.4.4 


closing rl!
closing rl!
codeMentorTutorial@0.0.1 /home/adam/apps/codeMentorTutorial
├── react-native-gradle-config@2.0.0 
└── UNMET PEER DEPENDENCY replace@*

npm WARN react-native-gradle-config@2.0.0 requires a peer of replace@* but none was installed.

我想在自己的repo上安装这个postinstall脚本,所以其他npm作者可以轻松地将它复制到自己的项目中。

有什么想法吗?这甚至可能吗?

0 个答案:

没有答案