Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can access to package.json config section?

Tags:

node.js

config

As I can see in https://npmjs.org/doc/config.html one way to expose config section of package.json to environment variables is use npm start command.

I found modules that loads package.json file as JSON and export config property after that. But the easiest way is define all configuration as module and require it on demand. Am I right? Any suggestions?

like image 336
Vladimir Kuznetsov Avatar asked Jan 25 '13 03:01

Vladimir Kuznetsov


People also ask

How do I access config json?

In the Project Explorer view, expand the plug-in project node. Expand the plugin folder node. Double-click the config. json file, or right-click the file and select Open with > PDK JSON Editor.

Where can I find package JSON file?

The package. json file is normally located at the root directory of a Node. js project. The name field should explain itself: this is the name of your project.

Where is npm config file located?

Built-in npm config file: /path/to/npm/npmrc.


1 Answers

You can also load the entire package.json as a module with require('./package') and the entire JSON object will be that module's exports, so you can do console.log(require('./package').version);, for example.

like image 200
Peter Lyons Avatar answered Oct 02 '22 03:10

Peter Lyons