我是Node.js的新手,尝试学习express来构建我的第一个Web应用程序.我被困在我的第一个示例代码上,需要一些帮助才能让它运行起来.在我发布这个问题之前,我确实搜索了堆栈溢出,发现了一些类似的问题,但仍然无法修复它.
错误:找不到模块'express'
我使用的是mac os 10.8.2.我一直在使用Node.js的安装nvm
.
node.js:0.8.20节点路径:/Users/feelexit/nvm/v0.8.20/bin/node要表达的路径:/ Users/feelexit/nvm/node_modules/express
这是我的示例代码:此文件位于:
/Users/feelexit/WebstormProjects/learnnode/node_modules/index.js
var express = require('express');
var app = express();
app.get('/', function(req, res){
res.send('welcome to express');
});
app.listen(3000);
Run Code Online (Sandbox Code Playgroud)
当我尝试运行此命令时 node index.js
我收到以下错误消息,请帮我解决.
谢谢.
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/Users/feelexit/WebstormProjects/learnnode/node_modules/index.js:1:81)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
feelexits-Mac:node_modules feelexit$
Run Code Online (Sandbox Code Playgroud)
更新回答chovy的问题:
feelexits-Mac:~ feelexit$ npm install
npm ERR! install Couldn't …
Run Code Online (Sandbox Code Playgroud) 在我的查询字符串中,我有一个年龄变量 ?age=New_Born
.
有没有办法可以检查这个字符串值New_Born
是否在我的枚举列表中
[Flags]
public enum Age
{
New_Born = 1,
Toddler = 2,
Preschool = 4,
Kindergarten = 8
}
Run Code Online (Sandbox Code Playgroud)
我现在可以使用if语句,但是如果我的枚举列表变大了.我想找到一个更好的方法来做到这一点.我正在考虑使用Linq,只是不知道该怎么做.
我有一个单选按钮列表.当我通过它们进行选项卡时,似乎只有第一个单选按钮或被选中的单选按钮才会聚焦,其余的单选按钮将被跳过.复选框没有这个问题.
我很难向我的QA解释这不是一个错误.有人可以向我解释为什么会这样.
Soccer: <input type="checkbox" name="sports" value="soccer" tabindex="1" /><br />
Football: <input type="checkbox" name="sports" value="football" tabindex="2" /><br />
<input type="radio" name="num" value="3" tabindex="3">3<br>
<input type="radio" name="num" value="4" tabindex="4">4<br>
<input type="radio" name="num" value="5" tabindex="5">5<br>
<input type="radio" name="num" value="6" tabindex="6">6<br>
<input type="radio" name="num" value="7" tabindex="7">7<br>
Baseball: <input type="checkbox" name="sports" value="baseball" tabindex="8" /><br />
Basketball: <input type="checkbox" name="sports" value="basketball" tabindex="9" />
Run Code Online (Sandbox Code Playgroud) 可能重复:
JavaScript/jQuery HTML编码
我有html标签需要编码.
<b>test</b>
Run Code Online (Sandbox Code Playgroud)
我需要将其编码为:
<b>test</b>
Run Code Online (Sandbox Code Playgroud)
我正在使用逃生,但它不起作用.
document.write(escape("<b>test</b>"));
Run Code Online (Sandbox Code Playgroud)
我得到的结果是
%3Cb%3Etest%3C/b%3E
Run Code Online (Sandbox Code Playgroud)
这不是我的预期.是否有另一种方法来使用JavaScript进行html编码?
我有一个监控图像文件夹的PowerShell脚本.我需要找到一种在计算机启动后自动运行此脚本的方法.
我已经尝试了以下方法,但我无法使其正常工作.
使用msconfig并将PowerShell脚本添加到启动,但我找不到该列表上的PowerShell脚本.
创建快捷方式并将其拖放到启动文件夹.没运气.
%SystemRoot%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -File "C:\Doc\Files\FileMonitor.ps1"
Run Code Online (Sandbox Code Playgroud)
或%SystemRoot%\ system32\WindowsPowerShell\v1.0\powershell.exe -File"C:\ Doc\Files\FileMonitor.ps1"
这是我的PowerShell脚本:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Doc\Files\FileMonitor.ps1"
Run Code Online (Sandbox Code Playgroud)我还尝试使用taskschd.msc添加基本任务.它仍然无法正常工作.
这是我发现的,也许这将有助于调试它.
如果我打开PowerShell窗口并在那里运行脚本,它就可以工作了.但如果我在CMD提示中运行它,
$folder = "C:\\Doc\\Files"
$dest = "C:\\Doc\\Files\\images"
$filter = "*.jpg"
$fsw = new-object System.IO.FileSystemWatcher $folder, $filter -Property @{
IncludeSubDirectories=$false
NotifyFilter = [System.IO.NotifyFilters]'FileName, LastWrite'
}
$onCreated = Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -Action {
Start-Sleep -s 10
Move-Item -Path C:\Doc\Files\*.jpg C:\Doc\Files\images
}
Run Code Online (Sandbox Code Playgroud)
不起作用.我不确定这是许可问题还是其他问题.
顺便说一下,我安装了PowerShell 3.0,如果输入$ host.version,它会在那里显示3.但我的powershell.exe似乎仍然是v1.0.
powershell.exe -File "C:\Doc\Files\FileMonitor.ps1"
Run Code Online (Sandbox Code Playgroud)我有一个kendoUI网格.
@(Html.Kendo().Grid<EntityVM>()
.Name("EntitesGrid")
.HtmlAttributes(new { style = "height:750px;width:100%;scrollbar-face-color: #eff7fc;" })
.Columns(columns =>
{
columns.Bound(e => e.Id).Hidden().IncludeInMenu(false);
columns.Bound(e => e.EntityVersionId).Hidden().IncludeInMenu(false);
columns.Bound(e => e.Name).Width("70%").Title("Entity Name");
columns.Bound(e => e.EIN).Width("30%");
})
.ToolBar(toolBar => toolBar.Template("<a class='k-button k-button-icontext k-grid-add' id='addEntity'><span class='k-icon k-add'></span>Entity</a>" +
"<a class='k-button k-button-icontext' id='editEntity'><span class='k-icon k-edit'></span>Edit</a>"))
.DataSource(dataSource => dataSource
.Ajax().ServerOperation(false)
.Model(model => model.Id(e => e.Id))
.Read(read => read.Action("GetEntities", "Entity", new { projectId = Request.QueryString[DataKeyNameConstants.ProjectId] })))
.Sortable()
.Scrollable()
.Filterable()
.Resizable(resize => resize.Columns(true))
.Reorderable(reorder => reorder.Columns(true))
.ColumnMenu()
.Selectable(s => s.Mode(GridSelectionMode.Multiple))
.Events(events => events.Change("entSelChange"))
)
Run Code Online (Sandbox Code Playgroud)
现在,我需要从选定的行中获取EntityVersionId的值.但不知道该怎么做. …
这里是简单的应用程序.如果我运行以下代码,我得到"运行:无法运行非主程序包"错误.
package zsdfsdf
import (
"fmt"
)
func Main() {
fmt.Println("sddddddd")
}
Run Code Online (Sandbox Code Playgroud)
修复它,我只需要将包命名为main.但我不明白为什么我需要这样做.我应该可以随心所欲地命名包装.
另一个问题,我知道主要功能是程序的切入点,你需要它.否则它将无法工作.但我看到一些没有主要功能的代码仍然有效.
点击此链接,页面底部的示例没有使用包main和main函数,它仍然有效.只是好奇为什么.
https://developers.google.com/appengine/docs/go/gettingstarted/usingdatastore
这是我的代码.它可以工作,如果你想遍历所有行.现在,QA告诉我,我必须支持过滤器.因此,当用户使用过滤器时,只有行的子集将显示在网格上.我只需要遍历那些行.
var entityGrid = $("#EntitesGrid").data("kendoGrid");
var data = entityGrid.dataSource.data();
var totalNumber = data.length;
for(var i = 0; i<totalNumber; i++) {
var currentDataItem = data[i];
VersionIdArray[i] = currentDataItem.VersionId;
}
Run Code Online (Sandbox Code Playgroud)
我试过了.
var data = entityGrid.dataSource.data().fetch();
Run Code Online (Sandbox Code Playgroud)
和
var data = entityGrid.dataSource.data().filter();
Run Code Online (Sandbox Code Playgroud)
无法让它运作.
我写了一个httphandler
来处理所有XSLT请求.
处理程序的名称是XSLTHandler.cs
.
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpHandlers>
<add verb="*" path="*.xsl" type="XSLTHandler" />
</httpHandlers>
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息,不知道如何解决它.
配置错误说明:处理为此请求提供服务所需的配置文件时发生错误.请查看下面的具体错误详细信息并相应地修改配置文件.
分析器错误消息:无法加载类型'XSLTHandler'.
我正在使用SQL Server 2008 r2.我想找到一种方法来验证SQL Server代理是否正在运行.我怀疑代理没有运行,但我不知道如何检查.
asp.net ×2
kendo-ui ×2
c# ×1
c#-3.0 ×1
c#-4.0 ×1
express ×1
go ×1
grid ×1
html ×1
html-encode ×1
httphandler ×1
ihttphandler ×1
javascript ×1
node.js ×1
powershell ×1
radio-button ×1
session ×1
sql-server ×1
web-config ×1