Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
567 views
in Technique[技术] by (71.8m points)

yarnpkg - How is `npm publish` different from `yarn publish`?

Is there a difference between yarn publish and npm publish? I have written a package, but for some reason, when I publish a new version using yarn publish I'm unable to import the package in my other projects. This is confusing because publishing withnpm publish results in working imports.

{
  "name": "@catpic/console-highlighter",
  "version": "0.1.6",
  "license": "MIT",
  "description": "Highlight console log messages with style.",
  "repository": {
    "type": "git",
    "url": "https://github.com/dlaub3/highlighter.git"
  },
  "directories": {
    "lib": "./lib"
  },
  "prepublish": "tsc -b",
  "main": "lib/index.js",
  "types": "lib/index.d.ts",
  "scripts": {
    "start": "parcel --out-dir serve index.html",
    "build": "tsc -b"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^4.11.0",
    "@typescript-eslint/parser": "^4.11.0",
    "eslint": "^7.16.0",
    "eslint-config-prettier": "^7.1.0",
    "eslint-plugin-prettier": "^3.3.0",
    "jest": "^26.6.3",
    "parcel-bundler": "^1.6.1",
    "prettier": "^2.2.1",
    "typescript": "^4.1.3"
  },
  "keywords": [
    "typescript",
    "javascript"
  ]
}
question from:https://stackoverflow.com/questions/65922489/how-is-npm-publish-different-from-yarn-publish

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In the end I needed to add the files field so that yarn would include the full contents of the lib folder.

 "files": [
    "lib/**/*"
  ],

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...