-
Notifications
You must be signed in to change notification settings - Fork 1
P. Running the finished product locally
So you've done it! You've made your very first npm package, but you are nervous about it actually working in someone else's project. Why not test it out locally!
Yellow-Stone:picnic-basket-generator yogibear$ npm pack
This command will create: picnic-basket-generator-0.1.0-beta.0.tgz
which your text editor will have no ability to read (or at least mine couldn't), but if you run:
Yellow-Stone:picnic-basket-generator yogibear$ open picnic-basket-generator-0.1.0-beta.0.tgz
You will notice that a package
directory appears in your project directory. This is your npm package! This is what the package
directory looks like based off of what we declared in our PJ & webpack.config.js
package/
dist/
picnic-basket-generator.js
picnic-basket-generator.js.map
picnic-basket-generator.min.js
picnic-basket-generator.min.js.map
lib/
index.js
rcjh.js
LICENSE
package.json
README.md
I made a script for running the package locally right from inside the actual package & created sandbox.js
for giving the package a go. You can also open a new project locally and import from there, totally up to you:
"test:package": "babel-node sandbox.js",
sandbox.js
const rcjh = require('./package/lib').rcjh;
// OR
import { rcjh } from './package/lib';
const result = rcjh();
console.log(result); // ROCK CHALK JAYHAWK, KU!