npm install of the published package produces an install that cannot run. Three separate causes, each of which alone is fatal, and none visible from a source checkout.
Symptom
On a machine with node and nothing else, installing the packed tarball and running the CLI fails on every language:
axiomcode: parser not built at .../parser/dist/index.js
After that is fixed, two more failures follow in sequence.
Causes
-
The built parser is not shipped. package.json has no files field, so npm falls back to ignore rules, and it honours a workspace's own .gitignore too. parser/.gitignore ignores dist/, so parser/dist is dropped while parser/src/test-data ships. Installs clean, fails on first use.
-
No bin entry. Nothing puts axiomcode on PATH, so there is no command after install. Adding it exposes the next one.
-
bin/axiomcode cannot find its own root when invoked through a symlink. npm installs a bin entry as a link in node_modules/.bin. The root walk starts at dirname "$0", which is then .bin/, climbs the user's project, finds a package.json with no graph/ beside it, runs out of parents and returns /. The tool then reports parser not built at //parser/dist/index.js and advises npm install && npm run build, which is neither possible nor correct on an installed copy.
-
No runtime dependencies are declared. dependencies is absent. The parser ships inside this tarball as parser/dist, but parser is a workspace, not a published package, so nothing installs what it requires. First use dies with Cannot find module 'typescript'.
Fix
files: list what ships. Explicit inclusion beats ignore rules, and a new build output is then included unless excluded rather than silently dropped.
bin: {"axiomcode": "bin/axiomcode"}.
bin/axiomcode: resolve $0 through symlinks before the root walk, and fail with a clear message if the marker is never found.
dependencies: hoist the parser workspace's runtime dependencies.
Side effect of files: the tarball drops from 81 MB to 3.1 MB (428 MB to 13.6 MB unpacked), because the test corpora stop shipping. All 145 engine rules still ship (java 55, typescript 26, python 38, javascript 26).
Evidence
Verified on a clean cloud VM with no souffle, no gcc, no make and no cmake, asserted absent before and after the node install. With all four fixes, installing only the two tarballs and running against four public OSS projects, one per language:
| language |
time |
tables |
| java |
11s |
40 |
| typescript |
7s |
63 |
| python |
25s |
103 |
| javascript |
7s |
52 |
Each run reports using packaged engine @axiomcode/engine-linux-x64, so the engine came from the package and nothing was compiled. The native parser dependencies (tree-sitter*) installed from prebuilt binaries with zero node-gyp invocations, so the no-compiler promise holds for the parser as well as the engine.
Relationship to #478
#478 makes the engine installable. These four defects sit in front of it: with them in place the engine is resolved correctly and the run still fails, because the parser half of the package is not installable. They are independent of the engine work and land on main.
npm installof the published package produces an install that cannot run. Three separate causes, each of which alone is fatal, and none visible from a source checkout.Symptom
On a machine with node and nothing else, installing the packed tarball and running the CLI fails on every language:
After that is fixed, two more failures follow in sequence.
Causes
The built parser is not shipped.
package.jsonhas nofilesfield, so npm falls back to ignore rules, and it honours a workspace's own.gitignoretoo.parser/.gitignoreignoresdist/, soparser/distis dropped whileparser/src/test-dataships. Installs clean, fails on first use.No
binentry. Nothing putsaxiomcodeon PATH, so there is no command after install. Adding it exposes the next one.bin/axiomcodecannot find its own root when invoked through a symlink. npm installs abinentry as a link innode_modules/.bin. The root walk starts atdirname "$0", which is then.bin/, climbs the user's project, finds apackage.jsonwith nograph/beside it, runs out of parents and returns/. The tool then reportsparser not built at //parser/dist/index.jsand advisesnpm install && npm run build, which is neither possible nor correct on an installed copy.No runtime dependencies are declared.
dependenciesis absent. The parser ships inside this tarball asparser/dist, butparseris a workspace, not a published package, so nothing installs what it requires. First use dies withCannot find module 'typescript'.Fix
files: list what ships. Explicit inclusion beats ignore rules, and a new build output is then included unless excluded rather than silently dropped.bin:{"axiomcode": "bin/axiomcode"}.bin/axiomcode: resolve$0through symlinks before the root walk, and fail with a clear message if the marker is never found.dependencies: hoist the parser workspace's runtime dependencies.Side effect of
files: the tarball drops from 81 MB to 3.1 MB (428 MB to 13.6 MB unpacked), because the test corpora stop shipping. All 145 engine rules still ship (java 55, typescript 26, python 38, javascript 26).Evidence
Verified on a clean cloud VM with no souffle, no gcc, no make and no cmake, asserted absent before and after the node install. With all four fixes, installing only the two tarballs and running against four public OSS projects, one per language:
Each run reports
using packaged engine @axiomcode/engine-linux-x64, so the engine came from the package and nothing was compiled. The native parser dependencies (tree-sitter*) installed from prebuilt binaries with zero node-gyp invocations, so the no-compiler promise holds for the parser as well as the engine.Relationship to #478
#478 makes the engine installable. These four defects sit in front of it: with them in place the engine is resolved correctly and the run still fails, because the parser half of the package is not installable. They are independent of the engine work and land on main.