nicoespeon / sass-graph-viz

Draw a visual graph of Sass dependencies
https://medium.com/@nicoespeon/i-built-a-tool-to-work-with-complicated-sass-codebases-b5c909e269fb
MIT License
26 stars 2 forks source link

Install fails, since no `dist` folder exists yet. #8

Closed jpblancoder closed 5 years ago

jpblancoder commented 5 years ago

I get the following error message when installing via npm.

➜  npm --version
6.5.0-next.0
➜  npm install -g sass-graph-viz
npm ERR! path /Users/jblanchette/.nvm/versions/node/v11.6.0/lib/node_modules/sass-graph-viz/dist/src/cli.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/Users/jblanchette/.nvm/versions/node/v11.6.0/lib/node_modules/sass-graph-viz/dist/src/cli.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

I believe this is due to no dist folder existing yet. But in package.json you have the following JS files that npm is trying to alias.

"bin": {
    "sassgraphviz": "dist/src/cli.js",
    "sgv": "dist/src/cli.js"
},
nicoespeon commented 5 years ago

Oh my… Sometimes, you mess things up. I totally did 🤦‍♂️

So, in short: I didn't notice the release was broken because I did npm link on my local repo, so everything looked fine—I had a dist/ folder since I created a build.

The problem was that I didn't put the source files in the released package. Thus, it couldn't build the dist/ files when installed. So it was basically unusable (except if you did clone the repo and npm link).

I fixed the release (using npm pack to check the produced package first). I published that under a patch version, so v2.2.1.

And it seems to work now: image

Thanks for spotting & telling me. I could have kept releasing broken packages without even noticing.

nicoespeon commented 5 years ago

Ok, I closed this too fast. Release is ok but it seems not to be usable as it couldn't find ../package.json.

This is weird since tsc is supposed to include it as part of compilation. It works with local build, but I checked the release build (after you install the package) and it's not present in the dist/ folder.

Working on it. Looks like I will publish a v2.2.2.

nicoespeon commented 5 years ago

Found the last issue. Turns out package.json should explicitly be listed in files to be included in the dist/ folder. This was subtle because the file is automatically part of the installed package with npm.

I got it installed & working: image

v2.2.2 has been published and you should be able to make the lib work with this.