Files generated by "prepublishOnly" script are not published during "npm publish". #15147
Comments
|
Sorry for the back and forth This is working as expected. |
The problem we (me and @wizardzloy) are solving here is that we use "peerDependencies", which are not installed with |
Why not just install that dependency as a |
I was thinking about that too, but I don't like the idea of having stuff in two places (peerDependencies and devDependencies). And IMHO devDependencies are tools for building, like bundling, transpilation, tests, lint and different similiar stuff that is not directly imported in source files. Also in npm docs there in devDependencies section there is:
... and I think it should remain like that. We definitely want target project to have these dependencies installed and use their own version of these packages. That's why the most logical place is only "peerDependencies" list here. |
@zkat what the |
@wizardzloy @vass-david what is it that this |
@zkat @vass-david the |
@wizardzloy: the intention behind How about this: Install your |
@zkat thanks for your help, this could be a solution indeed! |
@wizardzloy awesome! Cheers! :D |
Sorry to comment on a closed ticket. However, the In my case I want to run a script on I can't seem to achieve that because:
|
@Wildhoney I think the important question here is what the use case for something like this would be. In what usecase do you want to affect the potential contents of a tarball only when you're intending to upload it? |
@zkat on I have multiply "entry" files, and the // I can either configure "main" or move file to root.
import a from 'module';
// As far as I know, only supported by a move to root operation.
import b from 'module/b'; |
This is incredibly confusing. My understanding was that One example is that on my CI server I don't want to run want to prepare the package for publishing, I just want to download it and run tests. My This change doesn't make any sense to me in terms of making |
@clayne11 +1 This just makes absolutely no sense. In the last few weeks I spent countless hours having to publish my packages twice, because I couldn't understand why my version numbers were increasing but my code wasn't updating - I was using prepublishOnly to run babel and other stuff. I also spent a few hours today writing tests to send to the NPM Support team about this, until I inspected the verbose log of I'm definitely part of the 99% of people that @clayne11 describes. And that's very likely way more than 99%... On one hand, I'm glad to see it going away. On the other hand, I'm concerned about stability of the tool - things coming and going are a bit of a concern. Thanks |
Y'all who wanted to use That said, yeah, we're probably gonna get |
@clayne11 +1 I think there are 2 meanings of semantics in I had confusing about But, at I guess there was 2 semantics when I use In the 2 semantics, I guess the former one is now solved by |
As this repository is developed in npm@5, the 'prepublish' hook was being used to perform PRE-PUBLISH tasks (e.g. lint, test, transpile). However, it will still be executed via 'npm install' on older versions of NPM by a consumer of the package. This will cause the package installation to fail, as development dependencies/tasks are not intended to be downloaded/executed on 'install'. There is a lot of confusion around this: npm/npm#16685 npm/npm#15147 At the time of writing, there is no lifecycle hook available to perform a task ONLY prior to publishing, that is backwards compatible. A manual 'validate' script has been created to be used in it's place. Any publishing activity will need to make sure this script is run across all packages before the 'lerna publish' script is run. It should also be used in place of 'lerna bootstrap'.
As this repository is developed in npm@5, the 'prepublish' hook was being used to perform PRE-PUBLISH tasks (e.g. lint, test, transpile). However, it will still be executed via 'npm install' on older versions of NPM by a consumer of the package. This will cause the package installation to fail, as development dependencies/tasks are not intended to be downloaded/executed on 'install'. There is a lot of confusion around this: npm/npm#16685 npm/npm#15147 At the time of writing, there is no lifecycle hook available to perform a task ONLY prior to publishing, that is backwards compatible. A manual 'validate' script has been created to be used in it's place. Any publishing activity will need to make sure this script is run across all packages before the 'lerna publish' script is run. It should also be used in place of 'lerna bootstrap'.
adding to what @kyasbal-1994 said, I've just noticed that prepublishOnly ignores the exit code of the script, so for example I used to use prepublish to run "npm ls && npm test" which prevented me acidentially publishing broken stuff, other people run linters, etc. if prepublishOnly runs after pack, and can't effect whether or not publishing happens... I'm really not sure what prepublishOnly is even useful for? |
The `prepublishOnly` lifecycle is just so confusing, it doesn’t do at all what you would expect, but instead: “...prepubishOnly is not meant to be used for build steps. This lifecycle runs after tarball creation, right before we do the final upload. If you want to have a build step, please use prepare instead, as of npm@4.” Here is an issue and discussion about how it makes no sense: npm/npm#15147 (comment)
I'm opening this issue because:
What's going wrong?
If you have some build step defined in
prepublishOnly
script, the files produced by it are not included in the tar and aren't published whennpm publish
is calledHow can the CLI team reproduce the problem?
Clone https://github.com/wizardzloy/prepublish-bug , try to publish it, check that lib folder is not published even though it's generated during
prepublishOnly
phasesupporting information:
npm -v
prints: 4.0.3node -v
prints: v6.5.0npm config get registry
prints: https://registry.npmjs.org/The text was updated successfully, but these errors were encountered: