javascript,node.js,gruntjsRelated issues-Collection of common programming errors


  • Wim Barelds
    javascript android phonegap touch
    I’m building an app in phonegap. The app makes heavy use of javascript and has a content area that should be scrollable. However I also need to use the touchStart and touchEnd events.The problem is that, unless you use e.preventDefault on touchMove/touchStart, you will get the touchStart event only once and never again after that (Not useful). If you do e.preventDefault() on either of those two, native scrolling is disabled (on mobile devices).How do I allow native scrolling while also listening

  • Tarandeep Gill
    javascript parsing date safari
    I have a date string with the following format:2012-09-20T01:36:51.556ZIts a date field returned from mongodb as is. Chrome, FF, and IE are able to parse this string, however, Safari fails with an error Invalid Date. I have tried DateJS, but it fails to parse this date too. Any ideas how can I easily parse this date? Or, what particular thing is causing Safari to fail?I am using the native node driver for mongodb. And it returns date as a string in the above-mentioned format.

  • noder23
    javascript regex utf-8
    It seems Javascript’s native regular expressions fail to capture strings with interpolated line separator characters U+2028. For example when I try:”a\u2028b”.match(/(.*)/)I can capture only “a” and not the full string.Is there a reason for this behavior or it’s just Javascript failing to manage some utf-8 characters? Is there a way to work around this problem using Javascript’s native regular expressions?

  • Gabi Purcaru
    javascript html5-video jwplayer
    I’m trying to make jwplayer show the native iPhone play button (see below) on iPhone, and a custom skin elsewhere. I’ve tried to use chromeless: true, but it didn’t help (I still get the skinned play button). Now I’m stuck in jwplayer code and can’t find my way through. Can you help me out?

  • antonpug
    javascript dojo
    var testObj = this.getView();How can I check with DoJo (or just native JS) if testObj has callableFunction before I actually try to call callableFunction() and fail if it isn’t there? I would prefer a native-DoJo solution as I need this to work on all browsers.

  • everconfusedGuy
    javascript
    Lets say if I have a function a. I would like to know if its inbuilt function or a function defined by the user. I have tried checking if a.toString() has [native code] in it but user-defined functions which have the substring [native code] would fail. Is there any better way of doing this?

  • node ninja
    javascript flash
    I was looking for examples of Javascript games and I came across this. It looks like Flash. I tried looking at the source code, and all I see are a bunch of div tags, but not really any Javascript. I couldn’t find the code that actually runs the game.Is this Flash or Javascript? How can you tell?

  • alex
    javascript jquery forms jquery-ajax
    I’m using jQuery’s checkValidity() in ajax form submissions and everything works fine until the form has a select element.For example, I have a page that shows data based on the user’s choice of row count. (Select how many rows of data) … 10, 20, 30, etc. That’s the only form on the page. They select, and all is fine in every browser except IE 9 and below.Here’s the line in the form submission script that’s causing the error:if (!$(this).get(0).checkValidity()) {return false;}The error that is

  • Sean Anderson
    javascript iframe google-chrome-extension cross-domain
    I am developing inside of a Google Chrome Extension. In this environment, I have the ability to inject JavaScript into third-party websites after requesting the appropriate permissions. As such, I am injecting code into an iframe referencing a cross-domain resource, but am not bound by the same cross-origin security policies as would be expected in a ‘normal’ environment.The code I am executing inside of this iframe is:var requestId = window.requestAnimationFrame(function(){console.log(“Success”

  • user3307231
    javascript json cross-domain
    I want to execute the following AJAX call (cross domain):$.ajax({type: ‘GET’,url: url + “?callback=?”,contentType: ‘application/json’,async: false,jsonp: “callback”,dataType: ‘jsonp’, success: function (json) {alert(“ok” + JSON.stringify(json));},error: function (json) {alert(“err” + JSON.stringify(json));}});And I am getting this alert message:err{“readyState”:4,”status”:200,”statusText”:”success”}Which means the code ends in the error method.If I check the request in Firefox or Chrom

  • david
    node.js npm pg
    Trying to install pg. Here’s the full log:$ npm install pg –save npm WARN package.json [email protected] No description npm WARN package.json [email protected] No repository field. npm WARN package.json [email protected] No README data npm http GET https://registry.npmjs.org/pg npm http 304 https://registry.npmjs.org/pg npm http GET https://registry.npmjs.org/generic-pool/2.0.3 npm http GET https://registry.npmjs.org/buffer-writer/1.0.0 npm http 304 https://registry.npmjs.org/generic-pool/2.0.3 npm http 304 h

  • user1477955
    node.js visual-studio-2008 websocket
    I want to install:npm install websocketand I get the message:Native code compile failed!! On Windoes, native extensions require Visual Studio and PythonThen I installed Visual Studio 8 and Python, but I still get the message. How can Visual Studio compile the code?

  • Yu Jiang Tham
    node.js firmata
    My Johnny-Five apps are all failing after less than 1 second. I’ve tried with 0.7.9 and 0.7.8. This is the error I’m seeing:ytham:[master]~/js/deltarobot$ node . 1386668719984 Board Connecting… 1386668719986 Board -> Serialport connected /dev/cu.usbmodem1421 1386668723299 Board <- Serialport connected /dev/cu.usbmodem1421 1386668723299 Repl Initialized >> 1386668723348 Board string_decoder.js:109charStr += buffer.toString(this.encoding, 0, end);^ RangeError: toString() radix a

  • KajMagnus
    node.js build gruntjs
    When I run grunt watch, watch works once: Grunt compiles/minifies all files, after I’ve edited and saved a Javascript file. But when I edit and save that same file again, Grunt says ENOENT, no such file or directory ‘client/debiki/debiki-action-edit.js’.(The file mentioned is the file I just modified.) However the file does exist:$ ll client/debiki/debiki-action-edit.js -rw-rw-r– 1 kajmagnus kajmagnus 22497 Jan 21 23:47 client/debiki/debiki-action-edit.jsAnd if I run grunt directly from the c

  • Cordon Davies
    node.js mongodb express swig openshift
    I am trying to get my node/mongo/express app working on Openshift. It works locally, but on Openshift I am getting an Error: Cannot find module (‘swig’) I have added it to my dependencies in the package.json as shown below.”dependencies”: { “bcrypt-nodejs”: “~0.0.3”, “consolidate”: “~0.9.1”, “express”: “>=3.x”, “mongodb”: “~1.3.9”, “swig”: “~0.14.0”, “validator”: “~1.1.3” }, “devDependencies”: {}, “bundleDependencies”: [],And I require it in my server.js like so:var swig = require(‘swig’); va

  • TennSeven
    node.js selenium webdriver selenium-webdriver selenium-chromedriver
    So I had a Chromedriver / Selenium setup working before, but now trying to install everything on a new machine (64Bit Linux) it is giving me problems and not really telling me what is tripping up.I am using Selenium’s stand-alone server version 2.37.0 with nodejs and the latest version of Chromedriver available on Google right now (I also tried Chromedriver 2.0, an earlier version that I had working before, with the same results).As is shown in the output below, when I try to run a script utiliz

  • Mike Monteiro
    node.js azure odbc sql-azure
    I followed the tutorial here for building a node.js website on Azure that connects to a SQL-Azure DB:http://www.windowsazure.com/en-us/develop/nodejs/tutorials/web-site-with-sql-database/Here’s what my .js code looks like:var sql = require(‘msnodesql’), nconf = require(‘nconf’);exports.authenticate = function(req, res){var select = “select userID, clientID from users where username_e = ‘?’ AND pwd_e = ‘?'”; nconf.env().file({ file: ‘config.json’ }); var conn = nconf.get(“SQL_CONN”); console.log(

  • Matthew Clark
    javascript node.js schema mongoose
    Using Mongoose.js with node.js. I have this schema:var Photo = new Schema({URL:String,description:String,created_by:{type:ObjectId, ref:’User’},created_at:{type:Date, default:Date.now()} });var User = new Schema({name:{type:String,index:true},email:{type:String,index:true, unique:true} });//Task model var Task = new

  • Seeker
    node.js websocket socket.io
    I am trying to install socket.io using npm on a beaglebone (linux angstrom)/> npm install socket.ioit worked great on older versions of node with older kernel. I am using node v0.6.18 now.There seems to be a problem when npm tring to install ws which is supposed to install with socket.ioI get the same error if I try:npm install ws –ws:verboseHere is the result:root@beaglebone:~# npm install ws –ws:verbose npm http GET https://registry.npmjs.org/ws npm http 304 https://registry.npmjs.org/ws npm

  • pstenstrm
    node.js selenium2 internet-explorer-10 internet-explorer-11 saucelabs
    We’ve been using SauceLabs for our nightly Jenkins CI tests. We’ve run the tests in Firefox 24 under Windows 8 without any problem. Now we want to expand the tests and run them on more platforms and browsers. Our goal is to run the tests in the latest Firefox and Chrome browsers under Windows and OSX and IE11, 10 and 9.The tests are written using a node.js client for webdriver/selenium2 https://github.com/admc/wdThe problem I have now is getting our dragAndDrop method to work in IE11 and IE10. I

  • KajMagnus
    node.js build gruntjs
    When I run grunt watch, watch works once: Grunt compiles/minifies all files, after I’ve edited and saved a Javascript file. But when I edit and save that same file again, Grunt says ENOENT, no such file or directory ‘client/debiki/debiki-action-edit.js’.(The file mentioned is the file I just modified.) However the file does exist:$ ll client/debiki/debiki-action-edit.js -rw-rw-r– 1 kajmagnus kajmagnus 22497 Jan 21 23:47 client/debiki/debiki-action-edit.jsAnd if I run grunt directly from the c

  • Jon
    gruntjs jekyll grunt-contrib-watch
    I’m having some unexpected behavior with my Gruntfile. I’ve registered a task that looks like this: grunt.registerTask(‘dev’, [‘jekyll:server’, ‘watch:jekyll’]) with the hopes that it will sequentially start a jekyll server, and then watch my project for specific file changes (using the grunt-contrib-watch plugin). Once it detects those changes, it would re-run jekyll:server automatically.The problem I’m having is that when I run grunt dev, it will start the Jekyll server, but it will not run

  • u123
    gruntjs jshint
    I am running JSHint and Grunt on a bunch of javascript files. When I run grunt on my javaScript tests they all run successfully:……………………………………………..OK >> 2730 assertions passed (6565ms) >> Coverage: >> – Lines: 40.5% >> – Statements: 37.42% >> – Functions: 32.79% >> – Branches: 18%Done, without errors.I have now added JSHint so all my javascript source files are checked. In a javascript file I have introduced a small error

  • rainabba
    windows node.js gruntjs node-inspector
    Running Windows 8.1 and my environment is working great except I cannot start node in –debug so that node-inspector has something to connect to.I have a Gruntfile setup with grunt-concurrent that lets me open, grunt-devtools, node-inspector then watch just fine but I can’t figure out a workable syntax for getting that running with node in debug. Following is what I’d expect to work but also the error I get when I try. Notice that there is a message indicating that the debug server is listening,

  • Zacho
    angularjs jasmine gruntjs yeoman karma
    I have an app that uses Angular Translate (https://github.com/PascalPrecht/angular-translate). Translate works great in the application via browser but when I try to test any controller I get Error: Unexpected request: GET locale/locale-en.json. How do I unit test my controllers since translate does a GET request for the language file on startup?I am using the yeoman angular generator with Karma. App.js: angular.module(‘myApp’, [‘ngCookies’, ‘ui.bootstrap’, ‘pascalprecht.translate’]).config(func

  • u123
    javascript unit-testing gruntjs
    I am running javascript unittests with grunt/qunit. Sometimes the tests fails because of e.g syntax errors in the source files (works fine with file info if syntax errors are introduced in the test files). When that happens grunt simply prints the line number and not the file where the problem is.Running “qunit:all” (qunit) task Warning: Line 99: Unexpected identifier Use –force to continue.Aborted due to warnings.This does not help much since I have 100 of js files. I have looked into:https://

  • Android007
    gruntjs
    I’m using grunt to uglify my static files (using grunt v0.4.0). I have configured it to uglify one file, but I can’t figure out how to get it to do two files – despite reading this question and the usage examples. Here’s what I have currently:uglify: {options: {banner: ‘/*! <%= pkg.name %> <%= grunt.template.today(“yyyy-mm-dd”) %> */\n’,mangle: true},build: {src: ‘dist/main.js’,dest: ‘dist/main.min.js’} }I’d like to uglify dist/main.css as well. How can I add it? I tried this, follo

  • Connor Leech
    javascript angularjs gruntjs angularjs-ng-include
    When I deploy my unminified code everything works great. Then I run grunt build and deploy from the dist folder, as you do. When I check out one of the pages though it breaks and I get an error in the console: Error: [$parse:lexerr] Lexer Error: Unexpected next character at columns 0-0 [\] in expression [\]. http://errors.angularjs.org/1.2.6/$parse/lexerr?p0=Unexpected%20nextharacter%20&p1=s%200-0%20%5B%5C%5D&p2=%5Cat https://353a23c500dde3b2ad58-c49fe7e7355d384845270f4a7a0a7aa1.ssl.cf2

  • Evgeny
    gruntjs stylus
    I’m install grunt on windows 8. My gruntfile.js very simple:module.exports = function(grunt) {stylus: {files: {‘build/style.css’: [‘styles/style.styl’],}};autoprefixer: {// prefix the specified filesingle_file: {options: {// Target-specific options go here.}src: ‘build/style.css’;dest: ‘build/styles.css’;};};grunt.loadNpmTasks(‘grunt-autoprefixer’);grunt.loadNpmTasks(‘grunt-contrib-stylus’);grunt.registerTask(‘default’, [‘stylus’]);grunt.registerTask(‘stylus’, [‘stylus’]);grunt.registerTask(‘ap’

  • hereandnow78
    gruntjs nodeunit iced-coffeescript
    When I run iced nodeunit test …$ nodeunit path/to/file/file_name.iced… it’s ok.When I run a lot of coffee script tests …grunt.initConfig({nodeunit: {coffee: [‘path/to/coffee/nodeunit/tests/**/*_test.coffee’]}});$ grunt nodeunit:coffee… it’s ok. But when I try to run set of iced nodeunit tests with grunt nodeunit …grunt.initConfig({nodeunit: {iced: [‘path/to/iced/nodeunit/tests/**/*_test.iced’]} });… got errors: Fatal error: Unexpected string. Seemingly gruntjs don’t understand iced

Web site is in building