Replace a string in a file with nodejs

You could use simple regex: var result = fileAsString.replace(/string to be replaced/g, ‘replacement’); So… var fs = require(‘fs’) fs.readFile(someFile, ‘utf8’, function (err,data) { if (err) { return console.log(err); } var result = data.replace(/string to be replaced/g, ‘replacement’); fs.writeFile(someFile, result, ‘utf8’, function (err) { if (err) return console.log(err); }); });

What does -save-dev mean in npm install grunt –save-dev

–save-dev: Package will appear in your devDependencies. According to the npm install docs. If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use. In other words, when you run npm install, your … Read more

What is causing this error – “Fatal error: Unable to find local grunt”

I think you don’t have a grunt.js file in your project directory. Use grunt:init, which gives you options such as jQuery, node,commonjs. Select what you want, then proceed. This really works. For more information you can visit this. Do this: 1. npm install -g grunt 2. grunt:init ( you will get following options ): jquery: … Read more

NPM vs. Bower vs. Browserify vs. Gulp vs. Grunt vs. Webpack [closed]

Webpack and Browserify Webpack and Browserify do pretty much the same job, which is processing your code to be used in a target environment (mainly browser, though you can target other environments like Node). Result of such processing is one or more bundles – assembled scripts suitable for targeted environment. For example, let’s say you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)