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

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
Access to -aot parameter in code
Missing peer dependencies after installing latest angular-cli: What to do?
angular-cli ng serve : Error: No errors
Getting error after Angular cli update
Does angular-cli uses rollup to do ahead-of-time compilation and adding all into one file?
Angular CLI install error

Categories

HOME
paypal
pug
app-inventor
elixir
wsdl
google-tag-manager
fparsec
agile
otrs
travis-ci
search-engine
rocketmq
user
schemacrawler
google-classroom
flann
qt-installer
uiview
maxima
lstm
uicollectionview
arm-template
aptana
aws-cognito
sensu
epicor
remove-method
croppic
codelite
cgal
thinking-sphinx
hawtio
body-parser
salesforce-chatter
reactivemongo
phpspreadsheet
geomesa
pace
socketpair
brute-force
parent
productivity
pdftk
dojox.mobile
service-fabric-stateful
taglib
openweathermap
production-environment
gd
webdatagrid
goquery
pluck
openh264
ticker
react-native-fbsdk
typhoon
galleriffic
amf
gemini
gradle-release-plugin
django-south
post-processing
eyeql
site-prism
kendo-menu
subresource-integrity
programming-paradigms
pyrocms
calibration
digits
crash-dumps
coypu
ibm-data-studio
uos
google-hadoop
es2015
uptodate
sqoop2
android-search
cocoascript
gmaps4rails
microblaze
livechat
libssh2
power-law
colt
initialization-vector
openkinect
opendata
document-database
convex-polygon
nservicebus4
haskell-platform
pep8
maven-ear-plugin
moq-3
shim
xmlslurper
supersized
ubuntu-11.04
zookeeper
easygui
authenticode
rubycas
hadoop-plugins
code-design

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