I need to do npm install and link both in single cmd
So I am using
npm install -g NamPkg && npm link NamPkg
Is there any shorthand for this where I can mention NamPkg only once like :
npm install -g && npm link NamPkg
OR
npm install -g && link NamPkg
Bcoz I need to use this in Package.json and when the list grows more mentioning the same package names twice may become lengthy
"scripts": {
"preinstall": "npm install -g NamPkg && npm link NamPkg"
Is there any shorthand where I can mention NamPkg only once
AFAIK there is no way of doing this either via npm scripts or bash.
I don't know if it fits your use case, but using a variable would save a little typing (in that you would only have to declare the package name once and could copy/paste the rest of the command).
"scripts": {
"preinstall": "pkg='whatever'; npm i $pkg && npm link $pkg"
},