browserify

Cannot find module 'browserify'

本秂侑毒 提交于 2019-12-05 03:51:43
I'm getting this error: Error: Cannot find module 'browserify' When I add this line to my app/server.js file: var browserify = require('browserify'); Now I'm still new to Node, but I think I installed it correctly, via npm install -g browserify as per their docs . I'm pretty sure this is the command to check my global modules: D:\Websites\MySite> npm ls -g C:\Users\Mark\AppData\Roaming\npm ├─┬ browserify@1.17.2 │ ├─┬ buffer-browserify@0.0.4 │ │ └── base64-js@0.0.2 It lists browserify there. So why can't I require it? Anish Agarwal I was face same problem but if you want to install browserify

Using browserify, Uncaught ReferenceError: function is not defined

对着背影说爱祢 提交于 2019-12-05 02:04:22
I am trying example in http://browserify.org/ and try to make a function call as follows: My html is: <!DOCTYPE html> <html> <head> <title>Test Browserify</title> <script src="bundle.js"></script> </head> <body> <button onclick="hello()">test</button> </body> </html> and my javascript is: var unique = require('uniq'); var data = [1, 2, 2, 3, 4, 5, 5, 5, 6]; console.log(unique(data)); function hello(){ alert("here"); } I did browserify main.js -o bundle.js, so I can use require successfully. But when I click the button, I have the error: "Uncaught ReferenceError: hello is not defined" Any

How to import a npm package in an angular2 component?

流过昼夜 提交于 2019-12-05 01:59:49
I'm trying to learn the ropes of ng2 and the depedency injection system is killing me. I'm using the ng quickstart from: https://github.com/angular/quickstart/blob/master/README.md I'm trying to import this package into the app: https://www.npmjs.com/package/arpad . I installed the package via npm update, my package.json dependencies look like this: "dependencies": { "angular2": "2.0.0-beta.9", "systemjs": "0.19.24", "es6-promise": "^3.0.2", "es6-shim": "^0.35.0", "reflect-metadata": "0.1.2", "rxjs": "5.0.0-beta.2", "zone.js": "0.5.15", "arpad":"^0.1.2" <----- the package i'm trying to import

What is the difference between browserify external vs. exclude?

此生再无相见时 提交于 2019-12-05 01:25:19
I'm using browserify and trying to get it to skip wasting time including or parsing jquery and other require -less files I've loaded via CDN. Should I use bundle.exclude('jquery') or bundle.external('jquery') ? What is the difference? Their output seemed identical, and the docs are unclear to me: b.external : https://github.com/substack/node-browserify#bexternalfile Prevent file from being loaded into the current bundle, instead referencing from another bundle. If file is an array, each item in file will be externalized. If file is another bundle, that bundle's contents will be read and

Browserify require returns an empty object

我怕爱的太早我们不能终老 提交于 2019-12-04 22:24:03
I have this code which, for reasons I can't understand, produces an empty object when using require() . My file structure is like this: src |__ public |__ javascript |__ collections | categories.js | listings.js <-- Always an empty object |__ models | category.js | employer.js | listing.js | location.js | routing | templates | tests | ui-components | views The problem file is collections/listings.js , which seems to simply output as an empty object when required like so: var ListingsCollection = require('../collections/listings') src/public/javascript/collections/listings.js looks like this:

Backbone app with CommonJS and Browserify

心已入冬 提交于 2019-12-04 19:28:53
I thinking of bringing my existing app over to using CommonJS modules and using Browserify to bundle up the modules into one file. I'm getting my head around writing modules but the one thing I'm a little sceptical before I dive in and start re-writing certain bits, is how can I optimise it slightly so I don't have to include Backbone, Underscore, jQuery and any helper files in in each file, ie. var Backbone = require('/backbone'); var $ = require('/jquery'); var _ = require('/underscore'); At the top of each file is going to get a little tedious after a while. Being a complete CommonJS,

How to upload files from dropzone to cloudinary

不打扰是莪最后的温柔 提交于 2019-12-04 15:18:30
var myDropzone = new Dropzone("#product-image-drpzone", { // Prevents Dropzone from uploading dropped files immediately autoProcessQueue: false, addRemoveLinks: true, autoQueue: false, acceptedFiles: '.jpg,.png,.jpeg,.gif', url: 'https://api.cloudinary.com/v1_1/something/image/upload', //put it in the main url file once done maxfilesexceeded: function (file) { ToasterWrapper.errorMessage('You have uploaded more than 4 images!', false); return; }, init: function () { // You might want to show the submit button only when // files are dropped here: myDropzone = this; var imagesArr = [];

Browserify with Zurb Foundation Framework

Deadly 提交于 2019-12-04 14:08:07
POST-SOLUTION EDIT Here's a Yeoman generator to scaffold out a project with Foundation and Browserify: https://github.com/dougmacklin/generator-foundation-browserify I'm trying to figure out how to properly bundle the foundation framework js with browserify . In my project folder, I install it along with jQuery (which it depends on): npm install jquery foundation-sites --save Then in my main.js I have the following: var $ = jQuery = require('jquery'); var foundation = require('foundation-sites'); $(document).foundation(); I include the $ = jQuery = ... because if I don't I get a jQuery is not

gulp browserify bundle time takes too long

为君一笑 提交于 2019-12-04 11:06:15
I've ran into a strange issue and need your help to figure what's going on. I've configured gulp to build my a test up written in React.js in ES6. I've used browserify to setup the CommonJS env and babelify for bigger ES6 support. And everything works, it just takes too long (in my opinion) to build if React is required as CommonJS module. Meaning this import React from 'react'; line will raise the bundle/compile time from 1.2secs to around 4secs on the initial build, then when any changes are detected it takes around 2.5secs to rebuild the js files. And this time rapidly goes up when more

Browserify basedir option (RequireJS-like)

雨燕双飞 提交于 2019-12-04 10:47:34
问题 I cannot figure out how the browserify basedir option works.. Note : I may be wrong in my understanding of the whole basedir concept because I'm coming from RequireJS (think baseUrl ). EDIT Indeed I was wrong, but you can still achieve what I was trying to do with the paths option, see my answer below. I understand that the basedir option gives you the ability (the freedom!) to specify all require paths (starting with a . ) from a static root/base dir.. And NOT from process.cwd() .. This is