当我在JavaScript中使用require('on/a/path/that/doesn't/exis
What happens when I use require('on/a/path/that/doesn't/exist') in JavaScript?
我想根据条件动态读取需求文件
var clientName= "something";
var file = require('../somepath/ + clientName);
但是我想问如果路径不存在它会返回什么?我试图找到使用调试器,但它变得狂暴并结束调试!
将以Not Found error结束。require也会引发此错误。您可以在全局范围内捕获这些错误。查看此url http://requirejs.org/docs/errors.html#requireargs
您可以覆盖requirejs
的默认错误处理程序,并使用它来查看发生了什么
require.onError=function customErr(err){console.log('Custom:'+err)};
require(['../somedummyfile'])
相关文章:
- 正在使用$location.path(.)路由ng视图
- gulp Iconify任务抛出错误TypeError:Path必须是字符串.收到false
- Understanding Javascript scope with "var that = this&qu
- paper.js animation along a path
- 在函数中获取正确的作用域(不使用that=this)
- Animating text along an circular path with svg & javascr
- Raphael Path十字路口不工作
- res.sendFile(path.join(__dirname, '../public', '
- 在每个函数中处理“that”时奇怪的JS行为
- path没有方法'parse'在Meteor JS中
- Angular JS$location.path(..)未启动路由控制器
- $location.path获取上一个路径
- D3未捕获类型错误:path.data不是函数
- Angularjs$location.path()无法定位到当前路由器
- 获取笔刷内Path的d个值
- Joomla: image src path?
- AngularJS$location.path(path)最初未更新
- 正则表达式 path.match(/user/);.
- 为什么不't我的$location.path('test')更改地址栏
- 当我在JavaScript中使用require('on/a/path/that/doesn't/exis