requirejs

Installing axios using npm is undefined

怎甘沉沦 提交于 2019-12-13 03:25:01
问题 I am new to Axios and I am dealing with my first issue! I installed it with npm install axios and I get this error! enter image description here Also, I get an ENOENT error: no such file or directory, open /path/../../../ Can someone explain the reason? Thank you! UPDATED : I no longer get the ENOENT error. THE FIX : Was to change the name directory to something else rather than axios to axiosapi or anything else! NEW ISSUE : const axios = require('axios'); const api_url = 'https://opentdb

Using angularjs service ($cookies) in factory registered using couchpotato

旧城冷巷雨未停 提交于 2019-12-13 03:12:34
问题 I'm using angularjs with couchpotato for help with lazy loading. My question is how do I reference angularjs services like $http, $cookies in my service registered using couchpotato? The normal angularjs way: factory('MyService', function($cookies) { $cookies.message = "hello"; }); How do I do the above using angularjs with couchpotato.js? Below is my service with couchpotato: define(['app'], function(app) { app.couchPotato.registerFactory(['myFactory', [ function() { var factory = {};

Requirejs function in define not executed

痞子三分冷 提交于 2019-12-13 02:54:49
问题 My directory structure looks something like this: \js ... \models\... ... \test \test_runner.js \error_test.js ... main_tests.js Where I have the following code in main_tests.js : requirejs(['test/test_runner'],function(){ console.log('Testing begins'); }); The test_runner.js looks like this: define('test_runner',['test/error_test'],function(){ console.log("in test_runner"); }); and the error_test.js is like this: define('error_test',['modules/error'],function() { console.log('in erro_test');

Preserving jQuery dependency for highcharts with requireJS optimizer

倖福魔咒の 提交于 2019-12-13 02:35:20
问题 I'm testing out requireJS and am trying to make a simple project using highcharts. I've started with the requireJS multipage example project as a starting point. My dir structure looks the same as the base structure, with highstock.js added in the lib directory. page1.html : page 1 of the app. page2.html : page 2 of the app. js app : the directory to store app-specific modules. lib : the directory to hold third party modules, like jQuery. common.js : contains the requirejs config, and it will

UMD javascript module which also works in strict mode

≯℡__Kan透↙ 提交于 2019-12-13 02:15:02
问题 I'm having trouble rewriting this to work in 'strict' mode. Since 'this' is not defined explicitly I'm getting jshint errors on compile. I'm thinking my brain is just not thinking abstractly enough to find a creative solution. Any help would be appreciated. Code adapted from the Universal Module Definition Github repo: https://github.com/umdjs/umd/blob/master/returnExports.js (function (root, factory) { if (typeof define === 'function' && define.amd) { // AMD Module define([], factory); }

How to use Jasmine to test if an instance is created?

筅森魡賤 提交于 2019-12-13 02:12:38
问题 Hi Am new to using Jasmine. The issue is as follows: I have a number of modules, managed through RequireJS. Now a module A creates an instance of another module B in it. Is it possible to use Jasmine to test whether an instance of B is being created in A? To convey a clearer idea of the code, we have: //In module A define(['B',],function(B){ function test(){ var newTest = new B(); }; return {test: test}; }); Now, how do i use Jasmine to test that module A indeed, creates an instance of module

Cache Busting not working in CefSharp

时光怂恿深爱的人放手 提交于 2019-12-13 01:57:04
问题 I am using cefsharp (chromium embedded framework for .NET) to host a web application that uses require js to load in most of my javascript modules. To speed up my application I have enabled cacheing via response headers "Cache-Control: public,max-age=864000" for all my static content. When I deploy a new version of my web application i am appending a version number that gets incremented with every deployment in the urlArgs param of require.config() to perform a "cache bust" when my content

Null dependencies in RequireJS when ajax returns a 404

孤街醉人 提交于 2019-12-13 00:57:31
问题 Is there any way to have requireJS optionally (like maybe through a plugin) return null for a dependency that failed with a 404? For example: require(["allow404!myscript"], function(myscript){ console.info(myscript); // myscript should be null if myscript doesn't exist }); 回答1: You could abuse paths config fallbacks to achieve this: require(["myModuleOrNull"], function(myModuleOrNull) { console.log(myModuleOrNull); }); in your requirejs config: paths: { 'myModuleOrNull': [ 'unreliable-module

Require.js + Backbone optimization

*爱你&永不变心* 提交于 2019-12-13 00:53:41
问题 Good afternoon, I'm trying to optimize a source code based on Require.js and Backbone using r.js but I'm getting the following error during the compilation : Tracing dependencies for: main Cannot optimize network URL, skipping: empty:.js TypeError: Cannot read property 'normalize' of undefined In module tree: main app router views/main_panel/event_details helpers/template_manager My template_manager module does not try to access any 'normalize' property so I don't really understand what is

window.onload not running on page refresh

眉间皱痕 提交于 2019-12-12 21:37:10
问题 I just started using RequireJs. Only one problem. Can someone explain why the code inside the require block is not run on page refresh. It only runs when I clear the cache . example: require(['game','comm','misc','soundutil','sprite','gui','constants'],function(Game,COMM,MISC,SoundUtil,Sprite, Gui,CNT){ window.onload = function () { var canvas = document.getElementById('gameCanvas'), game = document.getElementById('game'), g = null,su = null; canvas.width = document.body.clientWidth; canvas