Skip to content

How to read environment variable from windows in node.js ? #2220

@kumaresan-subramani

Description

@kumaresan-subramani
  • Node.js Version: 10.16.3
  • OS: 10
  • Scope (install, code, runtime, meta, other?):
  • Module (and version) (if relevant):

Is there any way to read environment variable which is set in windows like below:

env

This is my requirement, in here I want to read above-mentioned variables values:

https://stackoverflow.com/questions/58236303/run-gulp-task-after-npm-package-install-without-any-command?noredirect=1#comment102845830_58236303

tagchange.js

var fs = require('fs');
var oldtag = process.env.oldtag;
var newtag = process.env.newtag;
var glob = require('glob');
 
require('dotenv').config()

console.log(process.env);

var files = glob.sync('./@syncfusion/*');
 
 for (var i = 0; i < files.length; i++) {
 var sourceFile = fs.readFileSync(files[i],'utf8');
 sourceFile = sourceFile.replace(`selector: '[ejs-button]'`,`selector: '[Kumar-button]'`);
// sourceFile = sourceFile.replace(oldtag,newtag);
 fs.writeFileSync(files[i], sourceFile, 'utf8');
 }

package.json

  "dependencies": {
    "postinstall": "*"
  },
  "scripts": {
    "postinstall": "node ./tagchange.js",
    "packagr": "ng-packagr -p ng-package.json && gulp npmrc-changelog-schematics-injection && gulp path-change"
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions