Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
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 answers
Answer question

0

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

More details can be found here

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!