require

Karma unit testing: Module name “react” has not been loaded yet for context: _. Use require([])

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to set up the unit testing framework for react. While doing so, the following error has occurred. I have searched all over the internet with no solution that is working. below are the errors shown and code/packages that I am using. debug error 04 03 2016 04 : 48 : 46.340 : DEBUG [ phantomjs . launcher ]: Error : Module name "react" has not been loaded yet for context : _ . Use require ([]) http : //requirejs.org/docs/errors.html#notloaded 04 03 2016 04 : 48 : 46.341 : DEBUG [ phantomjs . launcher ]: http : //localhost

$(…).datetimepicker is not a function

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I use webpack and want to use bootstrap-datetimepicker . In my webpack config I use ProvidePlugin to get "jquery module". In my code I get error $(...).datetimepicker is not a function when I call $('#datetimepicker12').datetimepicker function. I don't why $ variable doesn't contain datetimepicker function, which should be defined in var datetimepicker = require('eonasdan-bootstrap-datetimepicker'); webpack.config.js var webpack = require('webpack'); var merge = require('webpack-merge'); var NpmInstallPlugin = require('npm-install-webpack

Read json file content with require vs fs.readFile

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Suppose that for every response from an API, i need to map the value from the response to an existing json file in my web application and display the value from the json. What are the better approach in this case to read the json file? require or fs.readfile. Note that there might be thousands of request comes in at a same time. Note that I do not expect there is any changes to the file during runtime. request ( options , function ( error , response , body ) { // compare response identifier value with json file in node // if

react-router location did not match any routes

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am stuck with react-router routing. I am getting the error: Warning: [react-router] Location "/FluxApp/" did not match any routes This is my app.js : var React = require('react'); var ReactDOM = require('react-dom'); var Router = require('react-router').Router; var Route = require('react-router').Route; var IndexRoute = require('react-router').IndexRoute; var browserHistory = require('react-router').browserHistory; var App = require('./views/App'); var Home = require('./views/Home'); var Routes = ( ); ReactDOM.render(Routes, document

Webpack Missing Module 'Module Not Found'

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm currently working on a react webpack babel etc site and trying to build the first time. The build is successful, but when I open up the browser I get the following error: Uncaught Error: Cannot find module "/Users/michael.nakayama/Documents/Development/jamsesh/node_modules/webpack/node_modules/node-libs-browser/node_modules/process/browser.js" This module exists. Going to that actual url in my browser shows the file in question. But I cannot figure out why webpack cannot find it. I don't know if this is a babel6 issue or a webpack issue,

Node Express and csurf - 403 (Forbidden) invalid csrf token

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Looked through and tried everything I could find on here, and elsewhere by Googling...and I'm just not able to get past this. I'm using Node, Express, EJS, and attempting to use csurf on a form, that is posted w/ jQuery ajax. No matter how I configure csurf, I get "403 (Forbidden) invalid csrf token" I've tried configuring both globally in app.js and in the controller. Here's what I tried in app.js: var express = require('express'); var session = require('express-session'); var path = require('path'); var favicon = require('serve-favicon');

webpack can not require variable ,the request of a dependency is an expression

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: how to require a variable. i can work like this var config={ example1 : require("example1/main.js"), example2 : require("example2/main.js") } when I use like var modules=["example1","example2"] _.each(modules,function(module){ require(module+"/main.js") }) this error is "Cannot find module 'example1/main.js" 回答1: I had a similar problem and solved it by specifying the full path, e.g., in your case: var modules=["example1","example2"]; _.each(modules,function(module){ require("./"+module+"/main.js"); }); Maybe this example can help you. This

Warning: require(…): failed to open stream: No such file or directory in

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: just moved over my laravel site to my live server and straight away faced with this error. The complete error is: Warning: require(/var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/autoload.php on line 17 Fatal error: require(): Failed opening required '/var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/../vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var

How to require two versions of the same package?

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: in my project i need to use two versions of twitter bootstrap (v2.x and v3.x) 2 for the backend and 3 for the frontend. is it somehow possible to require both and tell composer to install them in different directoreies? something like that: { "name": "acme/hello-world", "require": { "twitter/bootstrap": "2.3.*", "twitter/bootstrap": "3.0.* as 'twitter/bootstrap3'" } } 回答1: You can't require two version, your application should only use one version of a package. 回答2: If you want you can overwrite the namespace inside loader object. Not

Rails: how to require at least one field not to be blank

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I know I can require a field by adding validates_presence_of :field to the model. However, how do I require at least one field to be mandatory, while not requiring any particular field? thanks in advance -- Deb 回答1: You can use: validate :any_present? def any_present? if %w(field1 field2 field3).all?{|attr| self[attr].blank?} errors.add :base, "Error message" end end EDIT: updated from original answer for Rails 3+ as per comment. But you have to provide field names manually. You could get all content columns of a model with Model.content