这两者之间的区别是什么:
var year = moment().format('YYYY');
var year = moment().year();
Run Code Online (Sandbox Code Playgroud)
它只是type of或其他什么?我只是好奇.
这就是事情.我的配置是Ubuntu 13.04,Node.js v0.10.5和NPM版本1.2.18.
我试图安装node.js模块"鞋",我收到此错误:
marek@nassenfuss:/media/tc/examples/node/05.01$ sudo npm install
npm http GET https://registry.npmjs.org/shoe
npm http 304 https://registry.npmjs.org/shoe
npm http GET https://registry.npmjs.org/node-uuid/1.3.3
npm http GET https://registry.npmjs.org/faye-websocket/0.4.0
npm http GET https://registry.npmjs.org/rbytes/0.0.2
npm http 304 https://registry.npmjs.org/node-uuid/1.3.3
npm http 304 https://registry.npmjs.org/rbytes/0.0.2
npm http 304 https://registry.npmjs.org/faye-websocket/0.4.0
> rbytes@0.0.2 install /media/tc/examples/node/05.01/node_modules/shoe/node_modules/sockjs/node_modules/rbytes
> node-waf configure build
sh: 1: node-waf: not found
npm WARN optional dep failed, continuing rbytes@0.0.2
shoe@0.0.10 node_modules/shoe
??? sockjs-client@0.0.0-unreleasable
??? sockjs@0.3.1 (node-uuid@1.3.3, faye-websocket@0.4.0)
marek@nassenfuss:/media/tc/examples/node/05.01$
Run Code Online (Sandbox Code Playgroud)
我在谷歌搜索,我发现node-waf被node-gyp取代.我还发现可以安装node-waf
sudo apt-get install nodejs-dev
Run Code Online (Sandbox Code Playgroud)
问题是我使用Chris Lea最新的node.js软件包,它不再包含dev.所以有两种方法可以解决这个问题. …
几分钟前,当我发现本地 Yarn 缓存/Users/user/Library/Caches/Yarn占用了超过 50GB 的磁盘空间时,我感到震惊。有没有搞错?为什么我的计算机上有这个 Universe 中的每个现有包?我很高兴 Yarn 宣传自己超快,但作为补偿,我不再喜欢吃那么多磁盘空间了。现在我什至明白为什么yarn cache clean需要数年才能完成它的工作。
Yarn 是否缓存特定包的所有版本?Yarn 开发团队是否有计划实施某种警告,即缓存占用大量空间并且可以清除?
新的jQuery 2.0.2将"style"属性添加到DOM树中的body标签.有什么具体原因吗?
PRINTSCREEN:

是否可以通过以下方式忽略特定文件中的打字稿错误tsconfig.json?我知道有他们网站exclude上描述的财产,但这不是我要找的。就像声明的那样:
如果文件 B.ts 被另一个文件 A.ts 引用,则不能排除 B.ts,除非在“排除”列表中也指定了引用文件 A.ts。
当你使用某个 npm 包时,它总是会被打字稿检查是非常合乎逻辑的。即使你努力到exclude整个node_modules或只是特定的一个。你会失败的。因此,如果某些节点模块文件中存在打字稿错误(由于某种原因、过时的类型、版本不匹配等),那么您就被卡住了。
我正在寻找的是一个选项,可以忽略我无法编辑的特定库文件中的打字稿错误。类似于// @ts-nocheck,但在tsconfig.json级别上:
{
"nocheck": [
"node_modules/redux-thunk/index.d.ts"
]
}
Run Code Online (Sandbox Code Playgroud)
该skipLibCheck编译器选项是不是一个解决方案。我仍然想继续检查其他图书馆。
我试图在我的VPS上运行Meteor,我收到了这个错误:
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Can't start Mongo server.
MongoDB had an unspecified uncaught exception.
This can be caused by MongoDB being unable to write to a local database.
Check that you have permissions to write to .meteor/local. MongoDB does
not support filesystems like NFS that do not allow file locking.
Run Code Online (Sandbox Code Playgroud)
我已经发现问题出在我的用户权限或类似的东西上.当我尝试使用root访问来运行流星时,它的工作非常顺利.如果我尝试用我的" custom"用户运行meteor ,它就会失败.即使我授予他在DigitalOcean上列出的sudo权限.为什么会这样?背后的问题是什么?
我在Ubuntu 14.04.1 LTS上.Meteor是版本0.8.3,我正在使用Meo的MongoDB.我没有分离MongoDB的安装.
更新:基本上我已经找到了问题,但我现在还没有找到导致问题的原因.我在DigitalOcean VPS上.如果我通过SSH运行Meteor,则会失败.如果我在Web控制台访问上运行Meteor,它就可以运行.我不明白.
我问自己,我做得对不对.我遇到的问题是我想在AngularJS更新textarea值后保留插入位置.
HTML看起来像这样:
<div ng-controlle="editorController">
<button ng-click="addSomeTextAtTheEnd()">Add some text at the end</button>
<textarea id="editor" ng-model="editor"></textarea>
</div>
Run Code Online (Sandbox Code Playgroud)
我的控制器看起来像这样:
app.controller("editorController", function($scope, $timeout, $window) {
$scope.editor = "";
$scope.addSomeTextAtTheEnd = function() {
$timeout(function() {
$scope.editor = $scope.editor + " Period!";
}, 5000);
}
$scope.$watch("editor", function editorListener() {
var editor = $window.document.getElementById("editor");
var start = editor.selectionStart;
var end = editor.selectionEnd;
$scope.$evalAsync(function() {
editor.selectionStart = start;
editor.selectionEnd = end;
});
});
});
Run Code Online (Sandbox Code Playgroud)
假设我开始在textarea中输入一些文本.然后我按下按钮,很快就会添加"期间!" 在$scope.editor价值的最后.在5秒超时期间,我再次关注textarea并编写更多文本.5秒后,我的textarea值会更新.
我正在关注$scope.editor价值.该editorListener会在每个执行$digest周期.在这个循环中也会发生双向数据绑定.我需要在数据绑定后纠正插入位置.是$scope.$evalAsync(...)我应该在哪里做,或者不正确的地方?
我遇到了 TypeScript 错误:
Failed to compile.
undefined
TypeScript error in undefined(undefined,undefined):
File name '/path/to/file/MyFileName.types.tsx' differs from already included file name '/path/to/file/myFileName.types.tsx' only in casing. TS1149
Run Code Online (Sandbox Code Playgroud)
myFileName找出和之间第一个字母的区别MyFileName。我不知道这是怎么发生的,也不知道如何解决。我以前从未见过这个错误。我正在使用 TypeScript 版本 3.5.3。如果有人至少能指出我该做什么,那将非常有帮助。
我在基本(512GB)DigitalOcean Droplet上运行简单的Meteor应用程序.有一段时间,Meteor只是崩溃了这个错误信息:

Out of memory: Kill process 9682 (node) ...
...
=> Exited from signal: SIGKILL
FATAL ERROR: JS Allocation failed - process out of memory
Run Code Online (Sandbox Code Playgroud)
怎么了?这是一个非常简单的应用程序,它无法花费所有的内存.
我在 Playground 中有一个 TypeScript 代码片段。请查看 TypeScript Playground或此处:
enum MyTypes {
FIRST = "FIRST",
SECOND = "SECOND",
THIRD = "THIRD"
}
type TFirst = {
type: MyTypes.FIRST
foo: string
}
type TSecond = {
type: MyTypes.SECOND
foo: string
}
type TThird = {
type: MyTypes.THIRD
bar: string
}
type TConditionalType<T> =
T extends MyTypes.FIRST ? TFirst :
T extends MyTypes.SECOND ? TSecond :
T extends MyTypes.THIRD ? TThird :
null
const getMyObjectBasedOnType = <T extends MyTypes>(type: T): TConditionalType<T> | null …Run Code Online (Sandbox Code Playgroud) NavLink包的组件react-router-dom支持添加额外的逻辑来确定链接是否处于活动状态。至少旧版本支持这一点。以下是文档链接:https://reactrouter.com/web/api/NavLink/isactive-func
代码片段:
<NavLink
to="/events/123"
isActive={(match, location) => {
if (!match) {
return false;
}
// only consider an event active if its event id is an odd number
const eventID = parseInt(match.params.eventID);
return !isNaN(eventID) && eventID % 2 === 1;
}}
>
Event 123
</NavLink>
Run Code Online (Sandbox Code Playgroud)
版本 6 中似乎isActive不再支持属性。还有哪些其他选项可以实现相同的功能?
有一段时间,我想开始使用带有React hooks 的 React 函数组件,而不是扩展 React 组件的类,但有一件事让我沮丧。这是 React Hooks 第一次介绍的一个例子:
import React, { useState } from 'react'
import Row from './Row'
export default function Greeting(props) {
const [name, setName] = useState('Mary');
function handleNameChange(e) {
setName(e.target.value);
}
return (
<section>
<Row label="Name">
<input
value={name}
onChange={handleNameChange}
/>
</Row>
</section>
)
}
Run Code Online (Sandbox Code Playgroud)
有一个handleNameChange声明用作输入的更改处理程序。让我们想象一下,Greeting由于某种原因,组件更新非常频繁。每次渲染时更改句柄都会初始化吗?从 JavaScript 的角度来看,这有多糟糕?
node.js ×3
npm ×3
typescript ×3
javascript ×2
meteor ×2
reactjs ×2
angularjs ×1
caching ×1
caret ×1
data-binding ×1
enums ×1
jquery ×1
memory ×1
momentjs ×1
mongodb ×1
node-modules ×1
process ×1
react-hooks ×1
scope ×1
styles ×1
sudoers ×1
undefined ×1
yarnpkg ×1