我从另一个项目中复制了package.json,现在想要将所有依赖项都添加到它们的最新版本,因为这是一个新项目,如果它破坏了我不介意修复它.
最简单的方法是什么?
我现在知道的最好的方法是运行npm info express version然后为每个人手动更新package.json.肯定有更好的办法.
{
"name": "myproject",
"description": "my node project",
"version": "1.0.0",
"engines": {
"node": "0.8.4",
"npm": "1.1.65"
},
"private": true,
"dependencies": {
"express": "~3.0.3", // how do I get these bumped to latest?
"mongodb": "~1.2.5",
"underscore": "~1.4.2",
"rjs": "~2.9.0",
"jade": "~0.27.2",
"async": "~0.1.22"
}
}
Run Code Online (Sandbox Code Playgroud)
我现在是npm-check-updates的合作者,这是解决这个问题的一个很好的解决方案.
我正在为一个相当典型的节点应用程序构建一个yeoman生成器:
/
|--package.json
|--.gitignore
|--.travis.yml
|--README.md
|--app/
|--index.js
|--models
|--views
|--controllers
Run Code Online (Sandbox Code Playgroud)
在我的yeoman生成器的templates文件夹中,我必须重命名dotfiles(和package.json)以防止它们作为生成器的一部分进行处理:
templates/
|--_package.json
|--_gitignore
|--_travis.yml
|--README.md
|--app/
|--index.js
|--models
|--views
|--controllers
Run Code Online (Sandbox Code Playgroud)
我看到很多生成器手动复制dotfiles:
this.copy('_package.json', 'package.json')
this.copy('_gitignore', '.gitignore')
this.copy('_gitattributes', '.gitattributes')
Run Code Online (Sandbox Code Playgroud)
我认为在添加新模板文件时手动更改生成器代码很麻烦.我想自动复制/ templates文件夹中的所有文件,并重命名前缀为_的文件.
最好的方法是什么?
如果我在想象的正则表达式中描述我的意图,那就是它的样子:
this.copy(/^_(.*)/, '.$1')
ths.copy(/^[^_]/)
Run Code Online (Sandbox Code Playgroud)
编辑 这是我能管理的最好的:
this.expandFiles('**', { cwd: this.sourceRoot() }).map(function() {
this.copy file, file.replace(/^_/, '.')
}, this);
Run Code Online (Sandbox Code Playgroud) 我还没有看到这个问题.每个浏览器都有不同的原生键盘快捷方式.如果我们想在我们的网络应用程序中添加一些辛辣的东西,有人已经试图找出哪一个免费/安全使用?
更多信息:
我并不特别需要针对每个浏览器.5个专业就足够了.例如,Opera使用Ctrl+ key作为主要组合,几乎所有Alt+ key"自由绑定".
由于不同的浏览器使用不同的主快捷键激活密钥(Ctrl在Opera中),我可以很容易想象也使用不同的密钥来绑定快捷方式.ie Alt+ Key在Opera中Ctrl+ + Key在browser_2中Ctrl+ + Alt在浏览器3中+ .
我有一个使用默认Jade视图引擎的Express应用程序.当我尝试在<pre>元素中按原样呈现HTML时,它将呈现为实际的DOM元素而不是文字字符.
h1 Code Sample
pre
code
<div>some text</div>
Run Code Online (Sandbox Code Playgroud)
输出:
<h1>Code Sample</h1>
<pre>
<code>
<div>some text</div>
</code>
</pre>
Run Code Online (Sandbox Code Playgroud)
如何转义HTML以使其呈现如下?
<h1>Code Sample</h1>
<pre>
<code>
<div>some text</div>
</code>
</pre>
Run Code Online (Sandbox Code Playgroud) 我目前使用grunt-shell从grunt任务运行shell命令.有没有更好的方法在一个任务中运行多个命令,而不是用'&&'将它们串在一起?
我的Gruntfile(部分):
grunt.initConfig({
shell: {
deploy: {
options: { stdout: true },
command: 'mkdir -p static/styles && cp public/styles/main.css static/styles'
}
}
});
Run Code Online (Sandbox Code Playgroud)
一系列命令不起作用,但它会很好:
grunt.initConfig({
shell: {
deploy: {
options: { stdout: true },
command: [
'mkdir -p static/styles',
'cp public/styles/main.css static/styles'
]
}
}
});
Run Code Online (Sandbox Code Playgroud) 我在 .vue 文件中有一个组件,可以从重用代码块中受益。我知道我可以将该代码移动到单独的 .vue 文件并将其作为新组件导入。但是,该组件不会在其他任何地方使用,我想避免使目录混乱。是否可以在不使用代码中的template:"<div>.....</div>"内容的情况下在父级中声明此组件的模板?
这是想法:
<template>
<div>
...some html here...
<div v-for="item in items">
{{item.name}}:
<div v-if="item.available">YES!</div>
<div v-else>NO :(</div>
</div>
...some other components and data here...
<div v-for="item in items">
{{item.name}}:
<div v-if="item.available">YES!</div>
<div v-else>NO :(</div>
</div>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
我希望能够做这样的事情:
<template>
<div>
...some html here...
<div v-for="item in items">
<itemizer inline-template v-model="item">
{{value.name}}:
<div v-if="value.available">YES!</div>
<div v-else>NO :(</div>
</itemizer>
</div>
...some other components and data here...
<div v-for="item in items">
<itemizer v-model="item"/>
</div>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
但是,据我所知,这是不可能的。
我很难输入打字稿来识别本地es6模块的形状:
convert-time.js
export const minutes = sec => sec * 60
export const hours = sec => minutes(sec) * 60
export const days = sec => hours(sec) * 24
export const weeks = sec => days(sec) * 24
export const years = sec => days(sec) * 365
Run Code Online (Sandbox Code Playgroud)
注意:我想弄清楚如何convert-time.js使它工作而不仅仅是更改为打字稿文件。
这是我要导入的文件:
索引
/// <reference path="../typings/convert-time.d.ts" />
import { minutes, days } from '../test/helpers/convert-time'
Run Code Online (Sandbox Code Playgroud)
这是我创建的类型定义文件:
convert-time.d.ts:
declare module "convert-time" {
export function minutes(sec: number): number;
export function hours(sec: number): number;
export …Run Code Online (Sandbox Code Playgroud) 我有一个简单的 npm 模块Emitter20,我正在尝试向其中添加类型定义。这是其源代码的全部 20 行:
module.exports = function() {
var subscribers = []
return {
on: function (eventName, cb) {
subscribers.push({
eventName: eventName,
cb: cb
})
},
trigger: function (eventName, data) {
subscribers
.filter(function (subscriber) {
return subscriber.eventName === eventName
})
.forEach(function (subscriber) {
subscriber.cb(data)
})
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是index.d.tsEmitter20 项目根目录中的文件:
declare module 'emitter20' {
interface IEmitter {
on: (eventName: string, cb: (data?: any) => void) => void;
trigger: (eventName: string, data?: any) => void;
} …Run Code Online (Sandbox Code Playgroud) 当我安装 npm 包jsonlines时,它被解析为镜像注册表registry.npm.taobao.org而不是registry.npmjs.org. 它仅针对 执行此操作jsonlines。这是什么原因造成的?
这是我的 package-lock.json 的差异。原始的“已解析”值是在另一个开发人员安装该包时创建的:
"jsonlines": {
"version": "0.1.1",
- "resolved": "https://registry.npmjs.org/jsonlines/-/jsonlines-0.1.1.tgz",
+ "resolved": "https://registry.npm.taobao.org/jsonlines/download/jsonlines-0.1.1.tgz",
"integrity": "sha1-T80kbcXQ44aRkHxEqwAveC0dlMw="
},
Run Code Online (Sandbox Code Playgroud)
我确认我配置的注册表是 npmjs.org:
$ npm config get registry
https://registry.npmjs.org/
Run Code Online (Sandbox Code Playgroud) 如何在我的.inputrc中覆盖bash中的Control + W?以下内容本身不起作用:
"\C-w": forward-word
Run Code Online (Sandbox Code Playgroud)
当我添加时它确实有效,stty werase undef但是's'键被神秘地禁用了!
我试图让 git 自动完成与 zsh 一起使用,但遇到了一个奇怪的错误(即使自动完成似乎成功完成):
\n安装:
\nmkdir -p ~/.zsh\ncd ~/.zsh\ncurl -o git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash\ncurl -o _git https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.zsh\nRun Code Online (Sandbox Code Playgroud)\n添加到~/.zshrc:
zstyle \':completion:*:*:git:*\' script ~/.zsh/git-completion.bash\nfpath=(~/.zsh $fpath)\n\nautoload -Uz compinit && compinit\nRun Code Online (Sandbox Code Playgroud)\n我打开一个新的 shell 并运行git checkout+“ty”+ tab,我希望它能够使用“typescript”自动完成,没有错误:
raine[npm-check-updates]% gc ty__git_find_on_cmdline:[:7: unknown condition: -lt \xe2\x9c\x93\n__git_find_on_cmdline:[:7: unknown condition: -lt\n__git_find_on_cmdline:[:7: unknown condition: -lt\npescript\nRun Code Online (Sandbox Code Playgroud)\n它会自动完成“打字稿”,但中间有一个错误,就在我点击选项卡的地方。是什么原因造成的?我该如何让它消失?
\n