weixin_39921689
weixin_39921689
2021-01-12 14:53

Publish to npm

Your instructions say that npm users should add cferdinandi/smooth-scroll as a dependency. If they want to depend on a specific version, they have to use the git tag syntax, e.g. cferdinandi/smooth-scroll#v7.0.2. However, they cannot specify a range of versions, using operators like ^, ~, etc.

Why not publish your library properly, so that users can manage yours like any other dependency? e.g. "smooth-scroll": "^7.0.0".

It's a really simple process: https://docs.npmjs.com/getting-started/publishing-npm-packages

该提问来源于开源项目:cferdinandi/smooth-scroll

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

10条回答

  • weixin_39883286 weixin_39883286 4月前

    See https://github.com/cferdinandi/smooth-scroll/issues/157 and https://github.com/cferdinandi/smooth-scroll/issues/62

    点赞 评论 复制链接分享
  • weixin_39921689 weixin_39921689 4月前

    Unfortunate.

    点赞 评论 复制链接分享
  • weixin_39938724 weixin_39938724 4月前

    What's so hard to sign up once on npmjs.org and run npm publish for every release? I really don't get it why you don't want to do what every other good library maintainer is doing?

    点赞 评论 复制链接分享
  • weixin_39921689 weixin_39921689 4月前

    The way I now think about this is, he's the one maintaining the library, so the only thing we can do is thank him for it. We'll have to figure out our side of things.

    点赞 评论 复制链接分享
  • weixin_39883286 weixin_39883286 4月前

    I hear you man. I'm a regular user of NPM-hosted projects myself, so I get your frustration. BUT... I manage several dozen open source projects, and regularly push updates, bug fixes, improved documentation, and general enhancements for almost all of them. Along with that, I also ensure that all of my gulp dependencies are relative up-to-date for anyone who's working with the source code.

    One instance of npm publish isn't that big of a deal, but in the context of a few dozen projects, in addition to compiling my code, running unit tests, waiting for the CI script to finish, pushing a version tag, updating docs, and then merging a PR from my development branch... it's a lot.

    So I'm sorry I'm not supporting NPM in your preferred way, but I also get this question for Bower and other package managers as well. I can't do everything for everyone.

    点赞 评论 复制链接分享
  • weixin_39938724 weixin_39938724 4月前

    If it is too much work for you to run the command by hand, setup travis to push the package to npmjs.org when creating a tag. http://docs.travis-ci.com/user/deployment/npm/ Then you don't have to do anything after setup once :)

    点赞 评论 复制链接分享
  • weixin_39881760 weixin_39881760 4月前

    What I see all across the closed PRs on this repository is that the project owner doesn't want to maintain support for the increasing number of package managers out there, but he is missing the point.

    please re-evaluate your views on open source collaboration; we don't want to add more work for you, we want to do work for you :)

    点赞 评论 复制链接分享
  • weixin_39883286 weixin_39883286 4月前

    Fair point, but these files often require version numbers that need to be updated every time a version change happens. I've seen far too many well-intentioned volunteers stop maintaining things after a few months, resulting in out-of-date files that are worse for the community than none at all. Configurations like the one suggested above are an additional third-party requirement, and one more thing to fail or break.

    I feel strongly that if there's a feature someone wants that I won't support, the project get forked and maintained separately. I deliberately use an MIT license for maximum flexibility.

    点赞 评论 复制链接分享
  • weixin_39921689 weixin_39921689 4月前

    Setting up npm releases through Travis is pretty straightforward: http://docs.travis-ci.com/user/deployment/npm/

    It's a one-time thing. Would that be a reasonable compromise?

    点赞 评论 复制链接分享
  • weixin_39838302 weixin_39838302 4月前

    For anyone still there, this may seem obvious but I just added it manually to my package.json:

    "smooth-scroll": "https://github.com/cferdinandi/smooth-scroll.git#master"

    点赞 评论 复制链接分享

相关推荐