angular-cli


How to use nconf with Angular CLI?


I'm using Angular CLI (v1.0.0-beta.19-3) and added nconf to my project:
package.json
npm install nconf --save
npm install #types/nconf --save
I added the following in apps[0].scripts within my angular-cli.json file:
"../node_modules/nconf/usage.js"
I then created an index.ts file under src/app/config:
import * as _ from 'lodash';
import * as nconf from 'nconf';
nconf.argv().env().file('./config.json');
// Default values that can be overwritten
nconf.defaults({
DB_HOST: 'localhost',
});
export const config = {
DB_HOST: nconf.get('DB_HOST'),
};
Then, I ran ng build followed by DB_HOST=foobar ng serve.
However, when I launch the browser and go to http://localhost:4200, the console displays the following error messages:
Uncaught ReferenceError: require is not defined
Uncaught TypeError: fs.readdirSync is not a function (nconf.js:26)
The offending line of code in nconf.js reads:
//
// Setup all stores as lazy-loaded getters.
//
fs.readdirSync(__dirname + '/nconf/stores').forEach(function (file) {
var store = file.replace('.js', ''),
name = common.capitalize(store);
I'm not sure what to do at this point. How do I get around this issue?

Related Links

Angular CLI (ng) use single instead of double quotes
can't install angular cli on ubuntu 16.04
How to solve No 'Access-Control-Allow-Origin' header is present on the requested resource with angular 2 service written with angular-cli?
Usage of watch parameter in eject command of Angular CLI
Serving and testing a bundle after ng build
routerLink stopped working in #angular/cli
How to run Angularcli project with https
what is npm i bootstrap#next?
Angular-Cli Best way to manage notices
Puzzling angular-cli AOT error
Create Project with Angular 4 Release using angularcli
addons removed in angular-cli.json whats the replacement
angular-cli: ng serve command with config error
Augury Angular-cli When I installed the augury .Error is as follows
Teamcity for building Angular cli app
angular cli update issue on local folder

Categories

HOME
json
rest
caching
security
vhdl
jsviews
rotation
label
reportportal
mapbox-gl-js
bibtex
wampserver
flyway
docker-windows
contact-form-7
octopus-deploy
finite-group-theory
phoenix
titan
mule-studio
flexboxgrid
url.action
npm-install
tfs2013
badge
python-textprocessing
rhmap
dhtmlx-scheduler
vegan
pyscripter
swiftcharts
data-extraction
alchemy.js
viewgroup
taglib
stress-testing
php-ews
rapidweaver
walmart-electrode
jags
gauss
volume
iron.io
xib
icefaces
picasa
mongoose-populate
wcf-ria-services
excon
nofollow
dojox.charting
aerogear
bluesnap
except
test-class
drf-nested-routers
coldfusion-7
insert-into
code-readability
zuora
lmfit
retro-computing
sevenzipsharp
rx-groovy
sparse-file
debian-based
ticket-system
chaining
named-ranges
mser
grunt-express
ifft
chrome-for-android
sslexception
vmware-server
shortcuts
appfog
couchdb-lucene
parameterization
responsetext
driving-directions
webkit-transform
charts4j
clause
svn-hooks
open-graph-beta
scala-2.8
boost-date-time
swfloader
evb
virtualquery
economics
usergroups
cots

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App