Questions tagged [browserify]

Browserify is a tool that packages Node.js modules for a web browser.

browserify
Filter by
Sorted by
Tagged with
167 votes
19 answers
281k views

How to import jquery using ES6 syntax?

I'm writing a new app using (JavaScript) ES6 syntax through babel transpiler and the preset-es2015 plugins, as well as semantic-ui for the style. index.js import * as stylesheet from '../assets/...
Édouard Lopez's user avatar
77 votes
3 answers
37k views

Browserify, Babel 6, Gulp - Unexpected token on spread operator

I'm trying to get my Browserify/Babelify/Gulp working in my project, but it won't take the spread operator. I got this error from my gulpfile: [SyntaxError: /Users/mboutin2/Desktop/Todo-tutorial/...
Mike Boutin's user avatar
  • 5,317
92 votes
14 answers
216k views

SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' - Gulp

Consider the following two files: app.js import Game from './game/game'; import React from 'react'; import ReactDOM from 'react-dom'; export default (absPath) => { let gameElement ...
TheWebs's user avatar
  • 12.7k
65 votes
8 answers
149k views

Is there a way to render multiple React components in the React.render() function?

For example could I do: import React from 'react'; import PanelA from './panelA.jsx'; import PanelB from './panelB.jsx'; React.render( <PanelA /> <PanelB />, document.body ); ...
Bryan Grace's user avatar
  • 1,843
36 votes
5 answers
34k views

Browserify with require('fs')

I was trying to use browserify on a file that uses the fs object. When I browserify it, the call to require('fs') doesn't get transformed and require returns {}. Is there any workaround for this? I'...
Fred Finkle's user avatar
  • 1,977
112 votes
12 answers
50k views

Browserify - How to call function bundled in a file generated through browserify in browser

I am new to nodejs and browserify. I started with this link . I have file main.js which contains this code var unique = require('uniq'); var data = [1, 2, 2, 3, 4, 5, 5, 5, 6]; this.LogData =...
SharpCoder's user avatar
  • 18.7k
86 votes
9 answers
67k views

browserify error /usr/bin/env: node: No such file or directory

I installed node js and npm via apt-get install and all of the dependencies, then I installed browserify npm install browserify -g it goes through the process and it seems like it installed ...
Eddie Martinez's user avatar
38 votes
4 answers
38k views

require is not defined error with browserify

I'm new to browserify and trying to load npm modules in browser but I'm getting the following error: Uncaught ReferenceError: require is not defined I'm following the tutorial from http://...
King Julien's user avatar
  • 11.1k
28 votes
2 answers
35k views

How to import part of object in ES6 modules

In the react documentation I found this way to import PureRenderMixin var PureRenderMixin = require('react/addons').addons.PureRenderMixin; How can it be rewritten in ES6 style. The only thing I can ...
Boris Zagoruiko's user avatar
88 votes
4 answers
71k views

Is it okay to use babel-node in production

I have been developing a site using babel-node and browserify with the babelify transform, to support ES6 syntax. I am just wondering, can I run this in production as babel-node server rather than ...
svnm's user avatar
  • 23.6k
50 votes
3 answers
30k views

How do I use Browserify with external dependencies?

I am trying to slowly introduce Browserify into my site, but I don't want to rewrite all the js and I don't want duplicate instances of jquery and other libraries bundled with my Browserify build. If ...
cobbdb's user avatar
  • 631
42 votes
1 answer
11k views

Modules vs. Namespaces: What is the correct way to organize a large typescript project?

I'm pretty new to typescript and I'm writing a small prototyping framework for WebGl. I'm currently refactoring my project and have run into some problems as how to organize my project, as both (...
mode777's user avatar
  • 3,137
36 votes
2 answers
30k views

Defining global variable for Browserify

I'm using SpineJS (which exports a commonjs module) and it needs to be available globally because I use it everywhere, but It seems like I have to do Spine = require('spine') on every file that uses ...
sebastiannm's user avatar
23 votes
11 answers
67k views

Disable chrome react DevTools for production

I'm trying to browserify my react app for production using gulp and envify to setup NODE_ENV. So I can remove react warning, error reporting in the console, and even my code to disable some features ...
Poirette's user avatar
  • 261
19 votes
2 answers
47k views

Node JS fs module inside browser

I have a scenario where I want to export data to CSV from the client-side. I will have a textbox/area or whatever where the user can input data and then ideally with one click, a local CSV file will ...
magicode118's user avatar
  • 1,464
66 votes
1 answer
25k views

What is the difference between browserify/requirejs modules and ES6 modules [closed]

I'm still new to ES6 and module loaders and I'm currently looking at combining a browserify setup with ES6. I was wondering if I would still need browserify/requirejs if I'm using ES6 modules. Seems ...
joerideg's user avatar
  • 1,818
32 votes
3 answers
20k views

Babelify throws ParseError on import a module from node_modules

I'm working with Babelify and Browserify. Also, I'm using ES6 style module features by node module system. I would like to put all my own modules into node_modules/libs. For instance: test.js in ...
Preco Plusb's user avatar
21 votes
5 answers
16k views

Catching Browserify parse error (standalone option)

I'm using gulp + browserify to build and package my javascript library. Now there is one thing that bothers me: I'm running a simple server with livereload for development via gulp. This works fine, ...
Laurens Rietveld's user avatar
17 votes
3 answers
11k views

Compiling dynamically required modules with Browserify

I am using Browserify to compile a large Node.js application into a single file (using options --bare and --ignore-missing [to avoid troubles with lib-cov in Express]). I have some code to ...
Brad's user avatar
  • 162k
11 votes
2 answers
1k views

Browserifying libraries that were themselves browserified: relative paths error

I want to use a library that was build using browserify. The library built correctly and works fine when it is used by itself. Now that built library is in my vendors/ directory, and I try to require ...
Sam Fen's user avatar
  • 5,144
7 votes
2 answers
4k views

gulp, browserify, maps?

How do I enable source maps? I'm doing this: var browserify = require("gulp-browserify") gulp.task("compile:client", function() { gulp.src("src/client/app.coffee", { read: false }) ...
iLemming's user avatar
  • 35.3k
7 votes
1 answer
4k views

How to use the net module from Node.js with browserify?

I want to use the net module from Node.js on the client side (in the browser): var net = require('net'); So I looked up how to get Node.js modules to the client, and browserify seems to be the ...
Captain GouLash's user avatar
99 votes
6 answers
58k views

How to get minified output with browserify?

Just started to use browserify, but I cannot find documentation for how to get it spilling out minified output. So I am looking something like: $> browserify main.js > bundle.js --minified
Fdr's user avatar
  • 3,704
65 votes
5 answers
45k views

How to save a stream into multiple destinations with Gulp.js?

const gulp = require('gulp'); const $ = require('gulp-load-plugins')(); const source = require('vinyl-source-stream'); const browserify = require('browserify'); gulp.task('build', () => ...
Konstantin Tarkus's user avatar
45 votes
12 answers
96k views

React - Minified exception occurred

I have React js installed via NPM and using browserify to manage components in react. When an exception occurs in React, the console shows as "Uncaught Error: Minified exception occurred; use the ...
Raathigesh's user avatar
  • 2,316
45 votes
4 answers
16k views

How do I manage relative path aliasing in multiple grunt-browserify bundles?

This is tad long but I'll need the code example to illustrate my confusion. After which I am interested to the answer for the following: How do I use require('module') instead of require('../../src/...
Sukima's user avatar
  • 10k
41 votes
4 answers
14k views

Configure a generic jQuery plugin with Browserify-shim?

I'm using browserify-shim and I want to use a generic jQuery plugin. I have looked over the Browserify-shim docs multiple times and I just can't seem to understand what's going on and/or how it knows ...
Glen Selle's user avatar
  • 3,956
32 votes
2 answers
10k views

Gulp + browserify + 6to5 + source maps

I'm trying to write a gulp task allowing me to use modules in JS (CommonJS is fine), using browserify + 6to5. I also want source mapping to work. So: 1. I write modules using ES6 syntax. 2. 6to5 ...
user avatar
22 votes
3 answers
17k views

Using Bootstrap 3.0 with Browserify

I am trying to use Bootstrap 3.0 with Browserify 5.9.1, but getting the following error: Uncaught ReferenceError: jQuery is not defined What's the correct way to do this? Here are the relavant ...
Naresh's user avatar
  • 25k
18 votes
7 answers
39k views

Multiple React components in a single module

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 ...
Elad Lachmi's user avatar
  • 10.5k
7 votes
2 answers
3k views

Shimming dependencies of dependencies with browserify-shim

I'm trying to refactor a library that uses Browserify by shimming certain modules out of the bundle using browserify-shim. Specifically, the library uses require("codemirror") but I want to provide a ...
Ethan Jewett's user avatar
  • 6,010
3 votes
2 answers
2k views

Karma/Istanbul Code Coverage does not find functions and always returns 100%

I am attempting to add Code Coverage for my Karma tests, however although it finds the correct JS files that I'm testing, it does not find the functions inside those files. From what I have read so ...
CD-jS's user avatar
  • 1,135
1 vote
1 answer
3k views

how to use require in browser? js / html

I searched whole stackoverflow to fix it, but cant. So... I need to use NPM module in browser (index.html). Getting error "require is not defined" if using <script src="./script.js&...
lep1k's user avatar
  • 11
31 votes
4 answers
18k views

Browserify - multiple entry points

I am using Browserify within gulp. I am trying to compile down my tests to a single file as well. But unlike my main app, which I have working just fine, I am having trouble getting the tests to ...
Matt's user avatar
  • 2,805
30 votes
2 answers
15k views

Should I use Browserify or Webpack for lazy loading of dependencies in angular 1.x [closed]

I would like to have async loading of angular dependencies in a large application and I'm trying to decide between Browserify or Webpack for this. I know angular 2.0 will support this natively but for ...
Nikos's user avatar
  • 7,425
28 votes
1 answer
8k views

Create separate JavaScript bundles with a shared common library using Browserify and Gulp

For my team at work, I'm trying to set up a semi-automated JavaScript script and dependency management system with the help of Gulp and Browserify. I'm not even sure if what I'm trying to achieve is ...
justrhysism's user avatar
  • 1,125
22 votes
5 answers
8k views

Keep original typescript source maps after using browserify

Background: I am compiling 2 dependent TypeScript files to js, which produces also source maps (one source map per file) using tsc 1.0 I'm using -m commonjs and then use browserify to generate a ...
Eran Medan's user avatar
  • 45.3k
20 votes
4 answers
9k views

How do I use react.js without a bundler?

Recently I have been playing around with react.js and I like the speed that I can develop working UI components. I have now created quite a few components and I would like to distribute some of them ...
bruceceng's user avatar
  • 2,004
18 votes
4 answers
13k views

How do I exclude the "require('react')" from my Browserified bundle?

I'm using Browserify to bundle a ReactJS application. All my components include a require("react") at the top. This causes Browserify to include the ReactJS source in my bundle. But I'd like to ...
Andre Pena's user avatar
  • 58.1k
16 votes
1 answer
7k views

Node/NPM: Can one npm package expose more than one file?

I have made a JS library for web development, it consists of several modules, which build up multiple distribution builds. It's fine when it is distributed over cdn or for example using Bower. But ...
Ali Shakiba's user avatar
  • 20.9k
15 votes
2 answers
16k views

'jQuery is not defined' when use ES6 import

My code: import $ from 'jquery' import jQuery from 'jquery' import owlCarousel from '../../node_modules/owlcarousel/owl-carousel/owl.carousel' class App { … _initSlider() { $("#...
Serge's user avatar
  • 151
13 votes
1 answer
2k views

Require in browserify doesn't work variable name

I am trying to require a file with browserify using variables passed into a function: var playersOptions = { name: 'players', ajax: 'team-overview', route: { name: 'overview', ...
Jamie Hutber's user avatar
  • 27.6k
12 votes
3 answers
5k views

Missing observable methods RxJS 5.0.0-beta.0

I'm having a problem using RxJS with Angular 2. Most of methods suggested from Typescript definition file are not defined on my Observable object like... then I figured out, that methods does not ...
Miguel Lattuada's user avatar
11 votes
3 answers
10k views

How to use browserify to bundle a backbone app?

I'm running into a little trouble with browserify. The Goal I'm trying to build the basic TodoMVC single-page app with Backbone, only instead of heaps of <script> tags in my index.html, I'm ...
Mulan's user avatar
  • 132k
11 votes
3 answers
18k views

Require file with a variable in React JS

I'm trying to require a file with a variable in the path. Something like const langCode = this.props.langCode; // en let languageFile = require('../common/languages/' + langCode); Where langCode can ...
Boky's user avatar
  • 11.9k
8 votes
3 answers
21k views

Using Node.js modules in HTML

I have the following Node.js project (which is a Minimal Working Example of my problem): module1.js: module.exports = function() { return "this is module1!"; }; module2.js: var module1 = ...
Erel Segal-Halevi's user avatar
8 votes
2 answers
24k views

Can't walk dependency graph

My Javascript build process ends up inserting the keyword require() in the file. This is not supported in client side and causes a console error. I have added browserify per other SO answers, however, ...
Riza Khan's user avatar
  • 2,956
6 votes
2 answers
2k views

Compacting node_modules for client-side deployment

I'm implementing a client-side application in JavaScript using Node.js. Because I will be deploying the software on many machines, I would like to minimize the size of the package I distribute. In ...
Matthew Gertner's user avatar
6 votes
1 answer
5k views

Circular dependency issue with Typescript, CommonJS & Browserify

I'm in the process of moving a fairly large typescript project from internal modules to external modules. I do this because I want to create one core bundle, which, if and when required, can load ...
Flion's user avatar
  • 10.7k
4 votes
0 answers
3k views

Howto patch/shim crypto.getRandomValues for React Native

I am porting some packages created for NodeJS to React Native using ReactNativify to rewrite Node API object dependencies to their browserify equivalents. One of them is crypto. In transformer.js (or ...
Arnold Schrijver's user avatar

1
2 3 4 5
7