NPM package exit message at the very end
Did anyone know if it is possible to print a log message at the very end after npm install ?
To enable CLI tab autocompletion run:
mypackage completion >> ~/.profile
progress@1.1.8 node_modules/progress
kew@0.6.0 node_modules/kew
adm-zip@0.4.7 node_modules/adm-zip
request-progress@0.3.1 node_modules/request-progress
└── throttleit@0.0.2
....
But I want to give a message after downloading the dependencies, for example:
progress@1.1.8 node_modules/progress
kew@0.6.0 node_modules/kew
adm-zip@0.4.7 node_modules/adm-zip
request-progress@0.3.1 node_modules/request-progress
└── throttleit@0.0.2
To enable CLI tab autocompletion run:
mypackage completion >> ~/.profile
I tried this through a post install script but doesn't work
source to share
I am also facing this problem. My workaround was to use a custom script:
"scripts": {
"presetup": "npm install -g",
"setup": "node postinstall.js"
},
(I need my tool to be installed globally, hance -g
. This can of course be omitted.)
And then I asked my users to run this line instead of the normal npm install:
npm run-script setup my-package.tgz
Please note that the npm install is still working. It just won't show the final message.
source to share
The npm documentation doesn't"scripts"
say that you can use "postinstall"
(or just "install"
) the associated command runs after the package is installed ...
Since you say that you have already tried this, but did not ask any context in your question on how, let me just walk you through the process ...
For example, say it was in your package.json
:
{
...
"scripts": {
"postinstall": "node postinstall.js"
}
...
}
Then, in your project directory, you can create a postintall.js
script and put it in it:
console.log(
"To enable CLI tab autocompletion run:\n" +
"mypackage completion >> ~/.profile"
);