Get dependencies written in package.json from JavaScript code

・1 min read

This is just a memo about how to refer dependencies written in package.json from JavaScript code.

import pkg from './package.json';

const dependencies = Object.keys(pkg.dependencies);
const devDependencies = Object.keys(pkg.devDependencies);
const peerDependencies = Object.keys(pkg.peerDependencies);

It would be useful in case of specifying externals in rollup.config.js.

  external: Object.keys(pkg.dependencies)
Classic DEV Post from Jul 2 '18

Who's looking for open source contributors? (July 2 edition)

Please shamelessly promote your project. Everyone who posted in previous weeks is welcome back this week, as always.

Software Engineer

Sore eyes? now has dark mode.

Go to the "misc" section of your settings and select night theme ❤️

(There is also a pink mode)