我正在尝试按照这些说明安装NVM
我在终端输入了这个命令:
$ curl https://raw.github.com/creationix/nvm/master/install.sh | sh
Run Code Online (Sandbox Code Playgroud)
运行安装后,我重新启动终端并尝试使用以下命令安装Node.js:
$ nvm install 0.8
Run Code Online (Sandbox Code Playgroud)
但我得到了回应:
-bash: nvm: command not found
Run Code Online (Sandbox Code Playgroud)
我不确定我在这里做错了什么.
附加信息 -
我一直在寻找其他帖子和论坛的解决方案.我找到了另一个解决方案
$ git clone git://github.com/creationix/nvm.git ~/.nvm
Run Code Online (Sandbox Code Playgroud)
但每次尝试时都会超时.任何帮助,将不胜感激.谢谢.
我在我的页面模板中使用此功能来获取其类别的帖子:
<?php
if (is_page(19)){
?>
<ul>
<?php
global $post;
$args = array( 'category' => 'Testimonial' );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li class="testimonial"><?php the_content(); ?></li><br/>
<?php endforeach; ?>
</ul>
<?php } ?>
Run Code Online (Sandbox Code Playgroud)
但它正在检索所有帖子.不只是那些标有推荐信的人.知道我做错了什么吗?
我正在node.js上运行一个快速应用程序.该应用程序使用express-subdomain模块来帮助处理两个不同子域(sub1.example.com和sub2.example.com)的路由.我在AWS Elastic Beanstalk上托管应用程序.在我的生产环境中,一切都很棒.但是在我的本地机器上,我无法让它工作.我尝试将子域添加到我的主机文件中127.0.0.1 localhost sub1.localhost sub2.localhost
.虽然这允许我将子域添加到localhost,但模块不会将其识别为有效的子域,因此在我的根路由中搜索子域路由.
在main.js中:
var routes = require('./routes/index')(passport);
var sub1_routes = require('./routes/sub1')(passport);
var sub2_routes = require('./routes/sub2')(passport);
app.use(subdomain('sub1', sub1_routes));
app.use(subdomain('sub2', sub1_routes));
app.use('/', routes);
Run Code Online (Sandbox Code Playgroud)
我需要能够在本地处理这个问题.将一个小的更改推送到AWS测试,迭代等需要花费很多时间.
我在MongoDB中存储的一些数据遇到了一些问题(注意:我使用的是mongoose作为ODM).我有两个模式:
mongoose.model('Buyer',{
credit: Number,
})
Run Code Online (Sandbox Code Playgroud)
和
mongoose.model('Item',{
bid: Number,
location: { type: [Number], index: '2d' }
})
Run Code Online (Sandbox Code Playgroud)
买方/物品将具有父母/子女协会,具有一对多的关系.我知道我可以将Items作为嵌入的subdocs设置到Buyer文档,或者我可以创建两个单独的文档,其中对象id引用彼此.
我现在面临的问题是,我需要查询的项目它的出价比买方的信用较低,而且这里位置附近一定地理坐标.
为了满足第一个标准,似乎我应该将Items作为一个子目录嵌入,以便我可以比较这两个数字.但是,为了将位置与geoNear查询进行比较,似乎最好将文档分开,否则,我无法在每个子文档上执行geoNear.
有什么方法可以对这些数据执行这两项任务吗?如果是这样,我应该如何构建我的数据?如果没有,有没有办法可以执行一个查询,然后对第一个查询的结果进行第二次查询?
谢谢你的帮助!
我正在尝试设置mongodb和为EBS配置的EC2实例.我正在关注这个MongoDB演练.我使用ec2命令行工具创建了一个新实例:
ec2-run-instances ami-05355a6c -t m1.large -b "/dev/xvdf=:200:false:io1:1000" -b "/dev/xvdg=:25:false:io1:250" -b "/dev/xvdh=:10:false:io1:100" --ebs-optimized true
Run Code Online (Sandbox Code Playgroud)
它说实例已创建.但是,当我去aws控制台时,它没有显示出来.另外,当我跑:
ec2-describe-instances [instance id]
Run Code Online (Sandbox Code Playgroud)
它打印出正在运行的实例的信息
RESERVATION r-5c259387c 6724431926739
INSTANCE [instance-id] ami-05355a6c ec2-[ip-address].computer-1.amazonaws.com ip-172-31-41-121.ec2.internal running 0 m1.large 2015-11-06T03:18:26+0000 us-east-1c aki-88aarjns8 monitoring-disabled [ip-address] [internal-ip-address] vpc-778e98sy subnet-3060eb47 ebs paravirtual xen sg-d94097bd default true
BLOCKDEVICE /dev/sda1 vol-beb6posj 2015-11-06T03:18:30.000Z true
BLOCKDEVICE /dev/xvdf vol-e2b75aef 2015-11-06T03:18:30.000Z false
BLOCKDEVICE /dev/xvdg vol-29b65ard 2015-11-06T03:18:30.000Z false
BLOCKDEVICE /dev/xvdh vol-bfb65sdf 2015-11-06T03:18:30.000Z false
NIC eni-20sdff6d subnet-3060eb47 vpc-778ee212 672443198021 in-use [internal-ip-address] true
NICATTACHMENT eni-attach-c916sdfe 0 attached 2015-11-05T20:18:26-0700 true
NICASSOCIATION …
Run Code Online (Sandbox Code Playgroud) 我正在使用node-geoip模块并执行聚合查询.我执行查询的模式如下所示:
var mongoose = require('mongoose');
require('./location.js');
module.exports = mongoose.model('Region',{
attr1: Number,
attr2: String,
attr3: String,
locations:[mongoose.model('Location').schema]
});
Run Code Online (Sandbox Code Playgroud)
和
var mongoose = require('mongoose');
module.exports = mongoose.model('Location',{
attr1: Number,
latlong: { type: [Number], index: '2d' },
});
Run Code Online (Sandbox Code Playgroud)
我需要在聚合查询中执行$ geoNear操作,但我遇到了一些问题.首先,这是我的聚合方法:
var region = require('../models/region');
var geo = geoip.lookup(req.ip);
region.aggregate([
{$unwind: "$locations"},
{$project: {
attr1 : 1,
attr2 : 1,
locations : 1,
lower : {"$cond" : [{$lt: [ '$locations.attr1', '$attr1']}, 1, 0]}
}},
{
$geoNear: {
near: { type:"Point", '$locations.latlong': geo.ll …
Run Code Online (Sandbox Code Playgroud) javascript geolocation mongoose mongodb aggregation-framework
我正在使用 elasticbeanstalk 通过 AWS 托管一个应用程序。我正在使用工具带从我的本地机器推送我的应用程序。直到几周前,一切正常,但最近我的更改没有生效。我可以在 aws 管理控制台中看到我的应用程序正在被推送和部署,但更改没有通过。
我检查了环境事件日志以查看典型部署中是否有任何新内容,我看到的错误是
ERROR Update environment operation is complete, but with command timeouts. Try increasing the timeout period. For more information, see troubleshooting documentation.
ERROR During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version.
ERROR Failed to deploy application.
ERROR Unsuccessful command execution on instance id(s) 'i-8d88a587'. Aborting the operation.
Run Code Online (Sandbox Code Playgroud)
究竟是什么问题,我能做些什么来解决这个问题?
我在我的Wordpress主题中,我正在获取子页面以显示其信息.这就是我现在所拥有的:
<?php
$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query->query(array('post_type' => 'page'));
$staff = get_page_children(8, $all_wp_pages);
foreach($staff as $s){
$page = $s->ID;
$page_data = get_page($page);
$content = $page_data->post_content;
$content = apply_filters('the_content',$content);
$content = str_replace(']]>', ']]>', $content);
echo '<div class="row-fluid"><span class="span4">';
echo get_the_post_thumbnail( $page );
echo '</span><span class="span8">'.$content.'</span></div>';
}
?>
Run Code Online (Sandbox Code Playgroud)
我有五个应该出现的子页面,但只有三个正在返回.我在$ staff上使用print_r来查看其他页面是否在数组中,但它们不是.我不确定问题是什么.
我有一个正在运行的应用程序,我希望为不同的子域设置不同的路由。这是我尝试过的:
app.get('*', function(req, res, next){
if(req.headers.host == 'sub.example.com') { //if it's a sub-domain
app.use('/', sub_routes);
}else{
app.use('/', routes);
}
next();
});
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用。我收到 404 错误。当我app.use('/', routes);
在该块之外设置时,路由工作,但随后我无法根据子域设置它们。我猜问题是我试图在已经设置的路由中定义路由,但我不确定如何有条件地设置这些路由。我怎样才能做到这一点?
我正在尝试让源映射与 Sentry 一起用于 ReactJS 应用程序。我将 webpack 与 SentryWebpackPlugin 结合使用。webpack config 中的相关配置如下所示:
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
const SentryOptions = {
// sentry-cli configuration
authToken: process.env.SENTRY_AUTH_TOKEN,
project: process.env.SENTRY_PROJECT,
// webpack specific configuration
include: pathLibrary.resolve(__dirname, '..')
};
module.exports = {
devtool: 'hidden-source-map',
output: {
filename: '[name].[contenthash].js',
chunkFilename: '[name].[contenthash].js',
publicPath: '',
path: pathLibrary.resolve(__dirname, '..', 'public'),
sourceMapFilename: '../tmp/sourcemaps/[file].map'
}
}
if (DEPLOY_ENVS.includes(env)) {
module.exports.plugins.push(new SentryWebpackPlugin(SentryOptions));
}
Run Code Online (Sandbox Code Playgroud)
当我构建和部署应用程序时,我确实可以在 Sentry 中看到源映射和源代码,但是问题页面上显示的代码似乎不可读。这让我相信我在命名输出文件或源映射方面做了一些错误的事情。
node.js ×4
express ×2
javascript ×2
mongodb ×2
mongoose ×2
php ×2
subdomain ×2
wordpress ×2
amazon-ec2 ×1
ec2-ami ×1
geolocation ×1
localhost ×1
nvm ×1
odm ×1
routing ×1
sentry ×1
source-maps ×1
terminal ×1
webpack ×1