npm,browserify,uglifyjs , What the meaning of browserify . -t [envify --NODE_ENV production] | uglifyjs -cm > js/bundle.min.js


What the meaning of browserify . -t [envify --NODE_ENV production] | uglifyjs -cm > js/bundle.min.js

Question:

Tag: npm,browserify,uglifyjs

I saw this in flux chat examplethe.

browserify . -t [envify --NODE_ENV production] | uglifyjs -cm > js/bundle.min.js

Why is browserify . -t [envify --NODE_ENV production] used here?


Answer:

things after -t are transformers. They will be called before the bundeling process. They can be use to transform your code into pure javascript.

For example: reactify can transform JSX to plain javascript and babelify gives you the opporunity to use es6 features like arrow functions and convert them to plain javascript (es5) before starting the bundeling process.

Here you can show what Envify is for. Short: It can declare node evironment variables as plain strings.


Related:


Node js can't require modules installed globally in OS X


node.js,osx,npm
I installed module by sudo npm install -g xxx in OS X, and the command echoes the module was installed in /usr/local/lib/node_modules/xxx. But the require('xxx') still fails claiming `Cannot find module 'xxx'. Only installing the module locally again by sudo npm install xxx can fix the error. Anything need to...

Vue JS 0.12 Dynamic Components


javascript,components,browserify,vue.js
I upgraded to Vue 0.12 but it's left me with a tricky problem. I'm using Browserify/Vueify to transpile and concatenate single file component definitions. In my app component I "require" the needed components and assign to keys in the components object then use v-component="x" in the template to mount them....

NPM Error: self signed certificate in certificate chain


ssl,npm,tsd
I am following the Angular 2 quick start guide and I'm stuck right at the beginning of it. My company is filtering our network connections and modifying SSL negociation. In a man in the middle style they assign a self signed certificate as the CA of the destination's certificate. Therefore...

Proper npm install --save behavior?


npm
All documentation I have seen indicates that using --save argument with npm install should update the dependencies in package.json. This does not work for me. Packages install successfully without any error in the npm console output, but `package.json' remains unchanged. What am I missing? I have seen nothing in my...

Cannot find a submodule imported inside a module installed from npm


node.js,npm,reactjs,browserify,html-datalist
I would like to use a node.js module from https://github.com/asbjornenge/react-datalist using browserify. I did install the module locally at my working directory. In that directory, I created a javascript file, main.jsx var React = require('react'); var ReactDatalist = require('react-datalist'); var options = ['apple','orange','pear','pineapple','melon']; React.render(<ReactDatalist list="fruit" options={options} />, document.body); Then, I...

Why do I have to use vinyl-source-stream with gulp?


javascript,gulp,browserify
I am trying to use gulp and browserify to transform my .jsx files into .js files. var gulp = require('gulp'); var browserify = require('browserify'); var reactify = require('reactify'); gulp.task('js', function () { browserify('public/javascripts/src/app.jsx') .transform(reactify) .bundle() .pipe(gulp.dest('public/javascripts/dist')) }); ``` The above threw Arguments to path.resolve must be strings. I managed to...

Using npm to install grunt on nodeenv results in findup-sync error


node.js,gruntjs,npm
After establishing a node virtualenv using nodeenv, I use source /bin/activate to switch into the correct directory, update npm, and execute npm install -g grunt or npm install -g grunt-cli and I recieve the same error: npm ERR! Linux 3.13.0-53-generic npm ERR! argv "node" "/home/{redacted-home-dir}/NodeProjects/vue/bin/npm" "install" "-g" "grunt-cli" npm ERR!...

node user model is vomitting


node.js,express,npm
I am trying to get my hands dirty with making node api following this tutorial https://scotch.io/tutorials/authenticate-a-node-js-api-with-json-web-tokens problem is that when I execute $ nodejs server.js I get this error { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson: Failed to load c++ bson extension, using pure JS version {...

NPM : how to just run post-install?


node.js,npm,package.json
Just a simple question : in my node.js project, how could I just run the postinstall script, without running install before ? FYI, this is my package.json : { "name": "gestionclientjs", ..., "dependencies": { ... }, "repository": {}, "devDependencies": { ... }, "engines": { "node": ">=0.10.0" }, "scripts": { "test":...

return a js object from a javascript function that is called from a node cpp addon


node.js,npm,return-value
I am tyring to create and return a javascript function object from a function that is called from a c++ node addon. The object was getting created, but wasn't getting returned by the function. callback function that creates an object named cursor var callback_fn = function(record){ var res = new...

npm installs packages and dependencies in the project root directory


node.js,npm
I switched from Windows to Mac. When I'm trying to install npm modules, the packages and their dependencies are created inside the project root directory. On Windows the module was installing into ./node_modules, with all dependencies inside module folder. Is there something I need to configure to make it work...

sass file not compiled by gulp


css,node.js,sass,npm,gulp
I want to switch from less to sass so I installed gulp-sass with npm and modified my gulpfile to compile sass instead of less (nothing else changed). Sadly gulp doesn't compile my .scss file to css and after googling and trying all i could think of it still doesn't compile....

React from NPM cannot be used on the client because 'development' is not defined. The bundle was generated from Webpack


javascript,node.js,npm,reactjs,webpack
I'm creating a React Node.js app and I'm trying to generate a Webpack bundle containing the React source code I loaded from NPM. However, it seems that the React code from NPM cannot be used directly in the client. It triggers this error: Uncaught ReferenceError: development is not defined The...

Multiple React components in a single module


reactjs,gulp,browserify
I am new to the whole browserify thing. I have been trying to use browserify + reactify + gulp to transform, minify and combine a React application. As long as I have a single React.createClass with a single module.exports = MyComponent everything works fine. Since I have several shared components...

VS 2015 RC - Trying to fetch local plugin from remote registry


node.js,npm,cordova-plugins,visual-studio-cordova,plugman
I have a local plugin, which I'm trying to install to a Cordova project. Adding it through VS works like a charm, but when I'm building it, plugman tries to retrieve the plugin from the registry (npm http GET http://registry.cordova.io/[Plugin]/[Version]) and the build fails, because this plugin only exist locally....

Node Global Install Error


javascript,node.js,npm
I'm trying to make a Node module that, when installed with -g, will run by a single command from a terminal. All tutorials show its pretty straightforward, so I don't know what I'm missing. Here's what I've done: Package.json: ... "bin": { "myapp": "./lib/myapp.js" }, ... npm publish npm install...

MongoDB : querying documents with two equal fields, $match and $eq


database,node.js,mongodb,npm,aggregation-framework
What is the best way to return all documents in a collection if I want document.a == document.b? I've tried db.collection.aggregate([ { $match: { $eq: [ '$a', '$b' ] } }]) But it returns with no errors or results, because I assume it is literally matching strings "$a" and "$b"....

How is it possible that browserify can make server code run in the browser when servers need access to things like sockets?


javascript,node.js,browser,browserify
Am I simply ignorant of the features that some browsers offer or does this library use some strange workaround to implement these features?

lodash npm distribution in browser


npm,karma-runner,bower,lodash
I'm using lodash in my tests, Not using webpack or browserify (don't need to). I found that the default npm build differs from what's in bower. I could of course use bower version, but I'm curious if I can use npm's instead (it's already there for Gulp). For bower I...

Node.js app giving ERR_EMPTY_RESPONSE


javascript,node.js,mongodb,npm
I'm having serious issues with an app I am building with Node.js, Express, MongoDB and Mongoose. Last night everything seemed to work when I used nodemon server.js to `run the server. On the command line everything seems to be working but on the browser (in particular Chrome) I get the...

jquery appears in browserify bundle.js but not working in browser


javascript,jquery,node.js,npm,browserify
I'm following this short tutorial on getting started with Browserify Getting Started with Browserify. Despite following everything exactly jquery isn't working on the page when bundled,ie. the button element in my app.js code below is not appended to the body. Have checked everything I can think of using chrome dev...

Error: EMFILE: too many open files


javascript,node.js,request,npm
Using nw.js, I am just trying to save images in an array of img elements with different random names. But having a few errors, is something wrong with my code? for (i = 0; i < imgs.length; i++) { request(imgs[i].getAttribute('src')).on('error', function(err) { throw err }).pipe(fs.createWriteStream('data/imgs/' + randomString)) } imgs[] is...

How to create web client application with nodejs and npm like angularjs tutorial


javascript,angularjs,node.js,npm
I am new to nodejs, npm also angularjs. I have read and tried the angularjs tutorial project hosted on https://github.com/angular/angular-phonecat.git, which for me is really exciting because it shows how easy to maintain the modules with bower, testing with jasmine and karma and perform e2e with protractor using npm command,...

Not able to access variables in required file


javascript,gulp,require,browserify
I'm using browserify on a project and am running in to the following: I have a file test.js. In test.js there is nothing but the following: var test = 'test'; Now, in the same directory I have my main file 'app.js'. I require test.js and try to access the 'test'...

javascript node module.exports / require() code on the front-end


javascript,node.js,svg,browserify
I've been looking into using a library such as SVGO to be able to clean user submitted SVG code on the front end. SVGO is a node.js based library which typically works on the back end, so I've been trying to wrap my head around how to go about sending...

jsx command not found on mac terminal


node.js,npm,reactjs,jsx
Problem: I execute the following command from the macintosh terminal: $ jsx --watch src/ build/ I recieve the following output error from the terminal: -bash: jsx: command not found Relevant information: I am following the following tutorial: https://facebook.github.io/react/docs/getting-started.html I executed the following command from the tutorial with positive output: $...

Package.json not found error when updating using npm-check-updates


node.js,npm,package.json
I'm trying to update my node packages/modules and a lot of people (many from StackOverflow) recommended 'npm-check-updates' so I downloaded via npm and ran it. It gave me this error and I'm not sure what's wrong. Is something wrong with my PATH variable in system settings or something? I can't...

npm install error not installing BrowserSync package


node.js,cmd,npm,command-prompt,browser-sync
Trying to install BrowserSync I've followed the steps to install the package through the command line, installed node.js and then I went on to install npm through the command line. Now when I try to install browser-sync with the following line npm install -g browser-sync you will see it is...

How to let Webpack require a root node_module instead of an child package?


backbone.js,npm,webpack
I have installed backbone and backbone.babysitter trough npm. When I use backbone in my scripts like this: import Backbone from "backbone"; It loads the installed backbone version 1.2.1. This works fine until I want to use backbone.babysitter. When backbone.babysitter loads it needs to add properties to backbone itself. But the...

What is the meaning of npm view dependencies output?


node.js,npm
When executing npm view [email protected] dependencies the dependencies are not displayed uniformly. What does it mean if a dependency is marked with a single quote and green font? What does it mean if a dependency is in a white font? ...

Created a package.json file, but getting dependency errors when running npm install


javascript,json,node.js,npm
I know this is a common question and I tried researching on here, but none of the answers have seemed to help me thus far. I am following this tutorial to learn node, and after I try to install the package.json I received the following errors: npm ERR! install Couldn't...

Browserify: runtime in browser 'Cannot find module…' error


javascript,browserify
I'm trying to learn Browserify, and I have a test project where I am bundling two javascript files into one bundle.js and including it on the page. I get this error at runtime in the browser: Uncaught Error: Cannot find module './test1' I use the following command to bundle the...

Node.js - Browserify: Error on parsing tar file


javascript,node.js,parsing,tar,browserify
I'm trying to download a tar file (non-compressed) over HTTP and piping it's response to the tar-stream parser for further processing. This works perfect when executed on the terminal without any errors. For the same thing to be utilized on browser, a bundle.js file is generated using browserify and is...

404 on api authenticate for node restful


node.js,express,npm
I am using this tutorial https://scotch.io/tutorials/authenticate-a-node-js-api-with-json-web-tokens to learn about node with restful authentication. I am getting 404s in the route when I post at this http://localhost:8090/api/authenticate Here is the response that I get Cannot POST /api/authenticate and the console shows 404 POST /api/authenticate 404 2.465 ms - 30 here is...

NPM Error Parsing Json, Unexpected Token


json,node.js,npm
I'm trying to install grunt, but no luck. npm install -g grunt-cli --registry http://registry.npmjs.org/ gives this error: npm ERR! registry error parsing json npm ERR! Darwin 14.3.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "grunt-cli" "--registry" "http://registry.npmjs.org/" npm ERR! node v0.12.4 npm ERR! npm v2.10.1 npm ERR! Unexpected token <...

Node JS NPM modules installed but command not recognized


node.js,npm,bower
Node JS and NPM was working well before. Recently I have re-installed the Node JS, NPM and the problem started. After I install a module like example npm install -g bower, the module gets installed successfully but bower -v gives 'bower' is not recognized as an internal or external command,...

Combine js files from different directories via config using grunt


javascript,gruntjs,npm,minify
I'm using grunt and sass and I'm looking for a sass-like feature to import any JS file I like to and combine them to 1 file via some config depending on the directory I am in. Example directories: startpage file1.js file2.js importjs.json page1 file3.js file4.js importjs.json global global1.js global2.js Each...

Strange npm behavior when installing packages like grunt


node.js,gruntjs,npm,gulp,bower
I run the following command in my bash and I get the related results: [email protected]:~$ sudo npm install -g grunt-cli /usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt [email protected] /usr/local/lib/node_modules/grunt-cli ├── [email protected] ├── [email protected] ([email protected]) └── [email protected] ([email protected], [email protected]) and [email protected]:~$ grunt /usr/bin/env: node: No such file or directory I also have try to install...

creating multiple objects with browserify


javascript,oop,browserify
I am trying to use the design pattern as below: human.js function Human(name){ this.name = name this.sayName = function(){ console.log(this.name); } } var a = new Human("bob"); var b = new Human("ted"); However I haven't used browserify much and I don't know how to do this in browserify. What I...

Browserify dynamic seperate bundles


javascript,browserify,commonjs
My app loads an object of messages in a given language into the application. My structure is like so: /lang /en.js (100 kb file) /ru.js (100 kb file) /... many more app.js (this is `MyApp` as below) The language files are very big so I would like to create seperate...

Error when i try to install npm with putty


amazon-ec2,npm,install,runtime-error
here is what i get when i try to execute this command (the 3rd command - in ec2 amazon) The next step is to install NPM(Node package manager). Type the following commands: 1. git clone https://github.com/isaacs/npm.git 2. cd npm **3. sudo make install** and here is the error i get:...

Error while updating to latest pm2


node.js,npm,pm2
I tried updating pm2 with "npm install [email protected] -g" (Cent OS 6) but received the following error. Now, i am no longer able to use "pm2 list" (it says command not found). Your help will be highly appreciated. npm ERR! Linux 2.6.32-042stab094.8 npm ERR! argv "node" "/home/username/local/bin/npm" "install" "pm2" "-g"...

Difference between bower, browserify, requirejs, webpack?


javascript,requirejs,gulp,bower,browserify
I'm used to simple and small JS projects where the JS dependencies are concatenated and minified as part of the build process using something like gulp and the script tag in the html contains the hardcoded path to that minified JS file. It's not elegant and probably has several disadvantages,...

Simple browserify test only runs when built with --debug


browserify
I have a simple hello world script main.js: window.addEventListener('load', function() { "use strict"; document.getElementById('output').textContent = "Hello, browser."; }); If I build bundle.js with: browserify -r ./main.js > bundle.js It doesn't run in the browser. No errors, just doesn't execute. If I use: browserify -r --debug ./main.js > bundle.js It runs...

Npm package upgrade notification availlable?


node.js,npm,packages,software-distribution
I wrote a node package which contains breaking changes in the next release. Does there exist a way to notify developers about that via console while upgrading via npm?

Make available a library created using browserify and browserify-shim


javascript,browserify,browserify-shim
I want to create a JavaScript library for browser using Browserify / Browserify Shim and make it available within the browser from a global variable. I would want that the exports of the entry JS file would be attached on this variable. For example, in my library, I would have...

reduce a lot of require() function


javascript,browserify,commonjs
I have a lot of CommonJS modules and I need to add all of them to array. Therefore, I have a huge repeated code: //Container module var module1 = require('module1'), module2 = require('module2'), ... module25 = require('module25') var container = []; container.push(module1); container.push(module2); ... container.push(module25); module.exports = container; Is it...

Grunt tasks stuck in endless loop


javascript,node.js,gruntjs,npm,grunt-contrib-concat
Working on putting together a base Gruntfile.js for some upcoming projects. Starting in on a new computer so everything has been a fresh build. Installed Node and NPM using Homebrew, and then installed Grunt globally, as well as in my local directory. Here is my package.json: { "name": "timespent-prototype", "version":...