loading...

Get dependencies written in package.json from JavaScript code

twitter logo github logo ・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)
  ...
}
twitter logo DISCUSS
Classic DEV Post from Jul 10 '19

How is your portfolio built?

Masato Ohba profile image
Software Engineer

👋 Hey dev.to reader.

Do you prefer sans serif over serif?

You can change your font preferences in the "misc" section of your settings. ❤️