Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
What do I need in the package.json of my npm package, to install it to another project?

I'm trying to make a small-ish react component that can be used in other projects. This is what I have in my package.json so far:


{
  "name": "my-package",
  "version": "0.1.1",
  "private": true,
  "main": "./dist/lib.umd.js",
  "module": "./dist/lib.module.js",
  "source": "src/components/MyPackage/index.js",
  "exports": {
    ".": "./dist/lib.js",
    "./styles.css": "./dist/lib.css"
  },
  "dependencies": {
    "classnames": "^2.3.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  },
  "devDependencies": {
    "microbundle": "^0.15.0",
    "react-scripts": "5.0.1"
  },
  "peerDependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "microbundle --jsx React.createElement --jsxFragment React.Fragment --jsxImportSource react",
    "watch": "microbundle watch --jsx React.createElement --jsxFragment React.Fragment --jsxImportSource react"
  },
  "eslintConfig": {
    "extends": [
      "react-app"
    ]
  },
  "files": [
    "dist"
  ],
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

The exports fields, module and source are for microbundle to know what and where to bundle.

This repo is in a private bitbucket repository, and I've installed it like this: npm i git+ssh://git@bitbucket.org:myuser/mypackage.git, but it doesn't let me import the package. When looking in my node_modules/mypackage, I only see the package.json, and the README, but no js files.

The weird thing is this package works when I import it locally using npm link.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

  "publishConfig": {
      "registry": "https://registry.npmjs.org"
  }

More details can be found here

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda