Search code examples
reactjsnpmcodesandbox

npm package makes codesandbox show blank screen


for the first time, I made a react library to handle infinite scroll for window and element. the package works with no problem when I create a react app and install the package on it. but in code sandbox when I add the package to the dependencies, it goes blank and shows nothing till I remove the package

here is the package: https://www.npmjs.com/package/react-snp-infinite-scroller

here is a project that used it with no problem:

source: https://github.com/rezaerami/react-snp-infinite-scroller-docs

demo: https://rezaerami.github.io/docs-react-snp-infinite-scroller/

here is a sample code sandbox react application with no changes only added the package to dependencies:

https://codesandbox.io/s/clever-meadow-tuxjo


Solution

  • I guess that maybe because of missing main point and/or.gitfrom repository URL inside yourpackage.json`

    Provide responses for the required fields (name and version), as well as the main field:

    • name: The name of your module.

    • version: The initial module version. We recommend following semantic versioning guidelines and starting with 1.0.0.

    • main: The name of the file that will be loaded when your module is required by another application. The default name is index.js. Docs

    Try to add:

    "main": "index.js,
    "repository": {
       "type": "git",
       "url": "https://github.com/rezaerami/react-snp-infinite-scroller.git"
    },
    

    Also, I'd recommend to add a description, author, license, tags, keywords blocks that will help people find your package.

    See all package.json handling.