Created
October 20, 2019 14:30
-
-
Save necccc/785b92c93320596090fc233e44b35f98 to your computer and use it in GitHub Desktop.
Gist for "npm authoring basics" - https://nec.is/writing/npm-authoring-basics/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# deprecate a single version | |
npm deprecate [email protected] "this version is not supported any more, pelase update" | |
# deprecate everything below a version | |
# mind the double-qoutes around the version information! | |
npm deprecate my-module@"< 1.0.4" "critical bug fixed in 1.0.4, please update" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ npm i [email protected] | |
npm http fetch GET 200 http://registry.npmjs.org/my-module 760ms | |
npm WARN deprecated [email protected]: critical bug fixed in 1.0.4, please update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"files": [ | |
"dist", | |
"src" | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
// using babel as a global module or local dependency, | |
// exits with an error if the host hasn't installed depdencies or installed babel as global | |
"babel": "babel src --out dist", | |
// using babel as a local dependency | |
// works even if there is no global babel installed | |
"babel": "./node_modules/babel-cli/bin/babel src --out dist" | |
// using npx | |
// same as the previous one, but much shorter, nicer and readable | |
"babel": "npx babel src --out dist" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// your module compiled to commonJS | |
"main": "dist/module.js" | |
"browser": { | |
// use a request-like module based on Fetch in the browser | |
"request": "./shims/request-with-fetch.js", | |
// basically this happens | |
"code-for-node.js": "code-for-browser.js" | |
}, | |
// your code in ES Modules format | |
"module": "esm/module.js" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
// these can be ran outside the 'run' command | |
"start": "", | |
"stop": "", | |
"test": "", | |
// these are accessibe via 'npm run ...' | |
"build": "", | |
"clean": "", | |
// these run before or after the scripts they are bound to by name | |
"prebuild": "", | |
"preclean": "", | |
"postclean": "", | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# log in to an org | |
npm login --scope=@myorg | |
# init an npm project within a scope/org | |
npm init --scope=myorg | |
# publish a scoped, and public package | |
npm publish --access=public | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment