DEV Community

Cover image for create expo library (npm)

Posted on

create expo library (npm)

I have made CLI for create expo library.

Alt Text

Install globally

This package requires node >= 10.

install expo-library by

npm install -g expo-library
Enter fullscreen mode Exit fullscreen mode

Creating a New Library

Enter fullscreen mode Exit fullscreen mode

Answer some basic prompts about your module, and then the CLI will perform the following steps:

  • copy over the template
  • install dependencies via yarn or npm
  • link packages together for local development
  • initialize local git repo


Local development is broken into two parts (ideally using two tabs).

First, go to root dir of newly create library and edit component in index.js/ts file.

Second, go to example/ dir and run metro bundle by

cd example
npm start # runs your expo app bundler
Enter fullscreen mode Exit fullscreen mode

Now, anytime you make a change to your library in index.js or to the example app's example/App.js will fresh refresh component in example.

Publishing to npm

npm publish
Enter fullscreen mode Exit fullscreen mode

Make sure that any npm modules you want as peer dependencies are properly marked as peerDependencies in package.json.


See the Contributing page.

Discussion (2)

minasamir11 profile image
Mina Samir

While running npm installing in root directory gives me this error:

cd ./example && expo-yarn-workspaces postinstall

at makeError (/Users/mo/.nvm/versions/node/v12.18.4/lib/node_modules/expo-library/node_modules/execa/lib/error.js:59:11)
at handlePromise (/Users/mo/.nvm/versions/node/v12.18.4/lib/node_modules/expo-library/node_modules/execa/index.js:114:26)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async pEachSeries (/Users/mo/.nvm/versions/node/v12.18.4/lib/node_modules/expo-library/node_modules/p-each-series/index.js:8:3) {

shortMessage: 'Command failed with exit code 1: npm install',
command: 'npm install',
exitCode: 1,

dtobias profile image

Sounds interesting, does the published package also work for non-expo projects?