shrinkpack
shrinkpack copied to clipboard
install shrinkpack locally
Description
I can not install shrinkpack without --global option, but I have to.
Suggested Solution
Help Needed
May be there is some method how to install and use shrinkpack locally?
When I have tried, it wrote "no package-lock.json or npm-shrinkwrap.json found"
If I create a symlink to /usr/local/bin, it wrote the same
Hi, You should be able to do this, it is the recommended way to install ~syncpack~ shrinkpack.
Let's install ~syncpack~ shrinkpack into a brand new, empty Node.js project;
# make some throw away folder
mkdir temp
# navigate to it
cd temp
# turn it into a Node.js project
npm init -y
# install syncpack
npm install --save-dev shrinkpack
What happens when you run these commands? (Or the equivalent commands if you are on Windows).
temp> npm install --save-dev syncpack ? Why syncpack? temp> npm install --save-dev syncpack 130 ... up to date, audited 244 packages in 2s .... temp> npm install --save-dev shrinkpack ... added 145 packages, and audited 244 packages in 6s
temp> ./node_modules/.bin/shrinkpack node_modules - (I run it locally) ! no package-lock.json or npm-shrinkwrap.json found
Why syncpack?
My mistake, I had just been replying to issues on my other project syncpack before replying to you.
It is saying that "no package-lock.json or npm-shrinkwrap.json found", this could be because those files do not exist in the temp
directory.
If you run ls -lah
in the temp directory, what is listed?
Jamie, ls -la is ok. I've done a dozen of tests
temp> ls -la итого 116 drwxr-xr-x 3 michael michael 4096 мая 7 21:08 . drwxr-xr-x 9 michael michael 4096 мая 7 21:07 .. drwxr-xr-x 198 michael michael 4096 мая 7 21:09 node_modules -rw-r--r-- 1 michael michael 301 мая 7 21:09 package.json -rw-r--r-- 1 michael michael 101553 мая 7 21:13 package-lock.json
Thanks @mbykov, I just tried it myself and it all seemed to work
[] ~/Dev/temp npm init -y
Wrote to /Users/jmason/Dev/temp/package.json:
{
"name": "temp",
"version": "0.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "Jamie Mason <[email protected]> (https://github.com/JamieMason)",
"license": "MIT",
"description": ""
}
[] ~/Dev/temp ydd shrinkpack
✔ Choose the agent › npm
npm warn deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs
added 139 packages, and audited 140 packages in 4s
4 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
[] ~/Dev/temp node_modules/.bin/shrinkpack --help
Usage: shrinkpack [options] [directory]
Options:
-V, --version output the version number
-h, --help display help for command
Icons:
+ Added
- Removed
i Information
12:34 Time Taken
[] ~/Dev/temp node_modules/.bin/shrinkpack .
↓ @gar/[email protected]
↓ @npmcli/[email protected]
↓ @npmcli/[email protected]
↓ @npmcli/[email protected]
↓ @npmcli/[email protected]
↓ @npmcli/[email protected]
↓ @npmcli/[email protected]
↓ @npmcli/[email protected]
↓ @tootallnate/[email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
↓ [email protected]
shrinkpack +139 -0 00:05
[] ~/Dev/temp
BUT, I just noticed something, you are running the command on the node_modules
directory but it should be run against the root of your project like so.
- ./node_modules/.bin/shrinkpack node_modules
+ ./node_modules/.bin/shrinkpack .
I think if you make that change it should be ok.
Yes, great! So:
$ npm i shrinkpack (locally) $ ./node_modules/.bin/shrinkpack . (<- this . does the trick!)
Thank you!
You're welcome 👍 I've not worked on shrinkpack for a long time, so you may run into issues if anything major has changed in npm since then.