New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] npm-cli install works from npm repository, but fails from github repository for same package #7312
Comments
I believe that when you npm install from a github repo, the "prepare" script is run; it's not run when you install from a registry. Could that be the difference here? |
if you check CAF's package.json, the but in either case, I run those build and test scripts myself before publish, and they all pass. and I can run them in an installed copy of the package, and they run fine. something about how npm is running them is different in a way I haven't anticipated, and don't know how to triage/fix. |
I believe |
FYI: the main substance of my question here -- not which script runs or not at which time -- is the overall failure and the lack of ability/knowledge to debug it, and that issue remains. Would appreciate any insight or help in debugging. |
I can't recreate on Mac. For me, the git works ok, but tests fail at @getify What if we removed the Speaking of copyright banners, I do inject the copyright banners on my OS npm packages too. But I do it via PS. thanks for your books, courses and public speaking (and visiting us in London) |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
If I create an empty folder (like
~/tmp
) and inside it issue anpm install caf
, my package (published for years on the public npm repository) installs correctly. I can even go into it (~/tmp/node_modules/caf
) and runnpm install
andnpm run test:all
, and everything runs and tests all pass.However, if I try the same type of thing (in a clean empty directory!), but issue
npm install [email protected]:getify/CAF.git
to install from the github repo, the installation fails. The main branch (master
) of that github repository, atHEAD
is the exact same source that the latest npm package release was published from/with, so there shouldn't be any divergence in the files/config/etc.I can't quite figure out why the install from the git is failing, from the logs of the error that are printed, which I'm finding quite confusing:
Full log: 2024-03-24T22_29_12_729Z-debug-0.log
Unfortunately, the temporary location
/home/getify/.npm/_cacache/tmp/git-cloneXXXXXXwCe8XF
thatnpm
is cloning the git repo into is wiped out when things fail, so I can't go in and inspect that file system to figure out what might be going wrong with what's in there.Notice that this error message above says
Unknown file extension ".txt" for /home/getify/.../dist/esm/copyright-header.txt
. What's weird about this is:The
copyright-header.txt
file only exists undersrc/
, and it's not copied over todist/esm/
during the build of this package. So I don't know why that file would be in that location as indicated by that error message. It definitely shouldn't be, so something is behaving strangely in a way I have no idea how to understand.Even if there was a .txt file in that folder, what difference should that make to npm?
This error occurs during the running of the package's test suite. That command is normally run as
npm run test:ESM
, which is basicallyTEST_ESM=true node scripts/node-tests.js
. THAT test script, when run with theTEST_ESM=true
environment variable, spawns a child process to invoke thenode-esm-tests.mjs
script.If you check out that's script's code, from there that test script doesn't do anything unusual. It just imports the ESM version of the library (
dist/esm/index.mjs
) and runs the qunit test suite. There's nothing in my code that would be trying to parsecopyright-header.txt
as an ESM module.Seems like npm must be doing something different/unexpected here to be... a) getting that .txt file in the wrong location b) trying to parse is as an ESM file.
Expected Behavior
I expect an installation from git and from npm-repository to work the same, if the files are the same (as in this case).
If the test suite is going to run on such an installation (why?!), I expect that environment they're running in to be the same as I run right before I publish to the npm repository, such that if tests pass when publishing, they should pass when installing.
And even if the tests DID fail when installing via git, I wouldn't expect that this should fail and abort the install. The install should complete, and an error message could then say that the test suite didn't complete.
Moreover, the only npm lifecycle step (in
package.json
) I've specified to run the tests isprepublish
, which I'm not sure why is being triggered during this git-based installation. I'd honestly rather the tests NOT run in this case, but it's unclear if I have any way to control that with whatnpm install
command I issue.Steps To Reproduce
~/tmp
npm install [email protected]:getify/CAF.git
.txt
file extension being unrecognized.Environment
The text was updated successfully, but these errors were encountered: