我已按照此链接尝试mean.js在 ubuntu 服务器上安装堆栈。
关于grunt,在/opt/mean,我做了
sudo npm install -g bower grunt-cli
sudo npm install grunt --save-dev
sudo npm install
Run Code Online (Sandbox Code Playgroud)
但是,grunt还是grunt jshint在文件夹里面给出
找不到有效的 Gruntfile。有关如何配置 grunt 的更多信息,请参阅入门指南: http ://gruntjs.com/getting-started 致命错误:无法找到 Gruntfile。
请注意,npm start可以正常工作,并且http://server_domain_or_IP:3000可以显示示例应用程序。
有谁知道如何修复 grunt 错误?
我想做一个像plunker一样的游乐场.我刚刚注意到一个非常奇怪的生产行为(使用active modeCloudflare),而它的效果很好localhost.
通过iframe,操场预览index_internal.html可能包含链接到其他文件(例如,.html,.js,.css).iframe能够解释外部链接,如<script src="script.js"></script>.
因此,每当用户script.js在编辑器上修改他们的文件(例如)时,我的程序会将新文件保存到服务器上的临时文件夹中,然后刷新iframe iframe.src = iframe.src,它运行良好localhost.
但是,我意识到,在生产中,浏览器始终保持加载初始化 script.js,即使用户在编辑器中修改它并且在服务器的文件夹中写入了新版本.例如,我看到的Dev Tools ==> Network始终是初始版本script.js,而我可以script.js通过less左侧检查服务器中保存的新版本.
有谁知道为什么会这样?以及如何解决它?
编辑1:
我尝试了以下,但没有用script.js:
var iframe = document.getElementById('myiframe');
iframe.contentWindow.location.reload(true);
iframe.contentDocument.location.reload(true);
iframe.contentWindow.location.href = iframe.contentWindow.location.href
iframe.contentWindow.src = iframe.contentWindow.src
iframe.contentWindow.location.replace(iframe.contentWindow.location.href)
Run Code Online (Sandbox Code Playgroud)
我试图添加一个版本,它可以使用index_internal.html,但没有重新加载script.js:
var newSrc = iframe.src.split('?')[0]
iframe.src = newSrc + "?uid=" + Math.floor((Math.random() …Run Code Online (Sandbox Code Playgroud) 我想通过命令行自动缩小文件夹。然后我装了npm install -g minify-all,然后minify-all /opt/myapp/。它给:
minify-all /opt/myapp/
found file: /opt/myapp/addin_online/css/Common.css
/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:104
throw new Error(bin + ' not found !');
^
Error: uglifyjs not found !
at getPath (/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:104:17)
at Object.compress (/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:132:27)
at Object.minify (/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:83:10)
at /usr/local/lib/node_modules/minify-all/index.js:30:13
at /usr/local/lib/node_modules/minify-all/index.js:14:13
at Array.forEach (native)
at walk (/usr/local/lib/node_modules/minify-all/index.js:10:36)
at /usr/local/lib/node_modules/minify-all/index.js:16:13
at Array.forEach (native)
at walk (/usr/local/lib/node_modules/minify-all/index.js:10:36)
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这一问题?是minify-all使用正确的包装吗?
编辑1:我尝试过sudo npm install uglify-js -g
/usr/local/bin/uglifyjs -> /usr/local/lib/node_modules/uglify-js/bin/uglifyjs
/usr/local/lib
??? uglify-js@3.0.11
??? commander@2.9.0
? ??? graceful-readlink@1.0.1
??? source-map@0.5.6
Run Code Online (Sandbox Code Playgroud)
和 …
我定义hostService如下。情况是我首先hostService.addListener()在控制器中调用,然后控制器可能会发出一条消息$rootSceop.$emit,hostService应该处理它。
app.service('hostService', ['$rootScope', function ($rootScope) {
this.button = function () {
Office.context.ui.displayDialogAsync("https://www.google.com", {}, function () {});
}
this.addListener = function () {
$rootScope.$on("message", function (event, data) {
this.button()
})
}
Run Code Online (Sandbox Code Playgroud)
但是,问题是上面的代码会引发错误:
TypeError: this.button is not a function
Run Code Online (Sandbox Code Playgroud)
有谁知道如何修理它?
我有一个网站mean-stack.
通常,我的所有外部参考都列在 index.html
我意识到我正在使用的一个外部JS库(例如,https: //cdnjs.cloudflare.com/troublelibrary.js)与我的网站的一部分有一些混淆.所以我正在寻找的解决方法是不为特定路径加载它https://www.myexample.com/specific.
有谁知道如何在路由中实现这一目标?
编辑1 :(见这里的完整问题)
实际上,有昏迷的图书馆是history.js.我一直加载它的初始代码如下.因此https://localhost:3000/home总是在浏览器中https://localhost:3000/home(即,#因为不会添加history.js)
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>
<script src="https://cdn.rawgit.com/devote/HTML5-History-API/master/history.js"></script>
Run Code Online (Sandbox Code Playgroud)
然后,如果我尝试以下代码,Ben建议:
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>
<script>
var newScript = document.createElement('script');
newScript.src = 'https://cdn.rawgit.com/devote/HTML5-History-API/master/history.js';
document.head.appendChild(newScript);
console.log(window.location.href)
</script>
Run Code Online (Sandbox Code Playgroud)
我意识到第一次加载https://localhost:3000/home不会改变.但是,如果我刷新浏览器,它可以更改为https://localhost:3000/#/home.
所以附加脚本与直接引用不完全相同,有人知道为什么吗?
javascript lazy-loading angularjs html5-history angular-ui-router
我在 中有一个数据库www.myweb.io,其中有SSL. mongo 的版本2.6.12在服务器上:本地的 mongo 版本是3.4.1. 我想把它转储到我的本地机器上,修改它,然后恢复回来。
我试过
mongodump --host www.myweb.io --port 22 --username myname --password "mypassword"
Run Code Online (Sandbox Code Playgroud)
它给了我一个错误:
2017-11-20T20:57:07.775+0100 Failed: error connecting to db server: no reachable servers
Run Code Online (Sandbox Code Playgroud)
有谁知道我应该设置什么主机和帖子?
PS:在我的本地主机中,我可以使用 Robo 3T 中的以下设置连接到数据库:
1) 在 下Connection,指定localhost:27017
2) 在 下SSH,检查Use SSH tunnel,指定xxx.xx.xx.xx:22为SSH Address
在/etc/nginx/sites-enabled/myweb.io,有listen 443 ssl。
我熟悉variantOCaml的类型.例如,
type foo =
| Int of int
| Pair of int * string
Run Code Online (Sandbox Code Playgroud)
我知道如何定义Number和String在MongoDB中,但我的问题是,如何在MongoDB中定义为上面的变量类型:
var PostSchema = new mongoose.Schema({
num: { type: Number },
name: { type: String },
variant: ???
})
Run Code Online (Sandbox Code Playgroud)
有谁有想法吗?
编辑1:我刚刚找到了这个答案和这个答案.他们使用类或函数来模仿variant.它在前端的JavaScript中运行良好.但问题是,是否可以将它们放入Schema?
我已经在 Windows 10 上安装了 Windows Subsystem for Linux (WSL) 和 Ubuntu 16.04。然后我按照以下步骤安装了纱线:
sudo apt update
sudo apt install curl
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn
Run Code Online (Sandbox Code Playgroud)
它没有引发任何错误。然而yarn --version归来
$ yarn --version
/mnt/c/Users/chengtie/AppData/Roaming/npm/yarn: 12: /mnt/c/Users/chengtie/AppData/Roaming/npm/yarn: node: not found
Run Code Online (Sandbox Code Playgroud)
npm --version回
$ npm --version
: not foundram Files/nodejs/npm: 3: /mnt/c/Program Files/nodejs/npm:
: not foundram Files/nodejs/npm: 5: /mnt/c/Program Files/nodejs/npm:
/mnt/c/Program Files/nodejs/npm: …Run Code Online (Sandbox Code Playgroud) 我正在使用 Monaco Editor 来制作我自己的 IDE。我习惯provideHover在某些类型的代码下划线。看起来下划线的颜色不同DiagnosticCategory或有影响。MarkerSeverity目前好像只有4种下划线颜色。
/* Diagnostics */
enum DiagnosticCategory {
Warning = 0,
Error = 1,
Suggestion = 2,
Message = 3
}
Run Code Online (Sandbox Code Playgroud)
有谁知道如何添加更多种类的下划线颜色?
在 Google 表格中,我有一个由 backendcode.gs和 frontend两部分组成的附加组件index.html,其中 index.html 是单击菜单时显示的侧边栏。这是code.gs:
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('My add-on')
.addItem('Test', 'openSideBar')
.addToUi();
}
function onSelectionChange(e) {
Logger.log("Selection changed ");
}
function openSideBar() {
var html = HtmlService.createHtmlOutputFromFile('Index');
SpreadsheetApp.getUi().showSidebar(html);
}
function getCurrentSelection() {
var currentCell = SpreadsheetApp.getCurrentCell();
return { column: currentCell.getColumn(), row: currentCell.getRow() };
}
Run Code Online (Sandbox Code Playgroud)
这是onSelectionChange的文档。在Logger.log("Selection changed")当选择的是变化的确叫。但是,当用户单击单元格并更改选择时,我需要在前端通知或进行更改。
这是index.html:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
Test
<input type="text" id="formula" />
<script>
function onSelectionChangeJs(e) { …Run Code Online (Sandbox Code Playgroud) javascript ×3
angularjs ×2
node.js ×2
npm ×2
caching ×1
cloudflare ×1
gruntjs ×1
html-head ×1
iframe ×1
lazy-loading ×1
mean-stack ×1
minify ×1
mongodb ×1
mongodump ×1
mongoimport ×1
mongoose ×1
mongorestore ×1
object ×1
ocaml ×1
ssl ×1
this ×1
uglifyjs ×1
windows-subsystem-for-linux ×1
yarnpkg ×1