如何使用和谐标志启动全局 npm 模块
how to start global npm module with harmony flag
我写了一个可以全局安装的npm模块dm-npm。
我喜欢在那个模块中使用 co。
我如何告诉模块它在全局启动时以和谐标志运行?
这里是 package.json:
{
"name": "dm-npm",
"version": "0.0.3",
"description": "npm helper",
"main": "index.js",
"scripts": {
"test": "mocha --reporter nyan",
"start": "node --harmony ./bin/dm-npm"
},
"repository": {
"type": "git",
"url": "https://github.com/divramod/dm-npm.git"
},
"keywords": [
"npm",
"template"
],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/divramod/dm-npm/issues"
},
"homepage": "https://github.com/divramod/dm-npm",
"devDependencies": {
"chai": "^2.1.0",
"mocha": "^2.1.0"
},
"dependencies": {
"co": "^4.4.0",
"co-prompt": "^1.0.0",
"colors": "~1.0.3",
"shelljs": "^0.3.0"
},
"bin": {
"dmnpm": "./bin/dm-npm"
}
}
当 运行 一个协函数时,我收到以下错误消息:
> $ dmnpm init
/usr/local/lib/node_modules/dm-npm/index.js:152
co(function*() {
^
SyntaxError: Unexpected token *
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/local/lib/node_modules/dm-npm/bin/dm-npm:3:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
这是由
引起的
co(function*() {
var projectName =
yield prompt('project name: '.blue);
process.stdin.pause();
});
#!/usr/bin/env node --harmony
在脚本的顶部对我有用,在你的情况下 /bin/dm-npm
我写了一个可以全局安装的npm模块dm-npm。
我喜欢在那个模块中使用 co。
我如何告诉模块它在全局启动时以和谐标志运行?
这里是 package.json:
{
"name": "dm-npm",
"version": "0.0.3",
"description": "npm helper",
"main": "index.js",
"scripts": {
"test": "mocha --reporter nyan",
"start": "node --harmony ./bin/dm-npm"
},
"repository": {
"type": "git",
"url": "https://github.com/divramod/dm-npm.git"
},
"keywords": [
"npm",
"template"
],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/divramod/dm-npm/issues"
},
"homepage": "https://github.com/divramod/dm-npm",
"devDependencies": {
"chai": "^2.1.0",
"mocha": "^2.1.0"
},
"dependencies": {
"co": "^4.4.0",
"co-prompt": "^1.0.0",
"colors": "~1.0.3",
"shelljs": "^0.3.0"
},
"bin": {
"dmnpm": "./bin/dm-npm"
}
}
当 运行 一个协函数时,我收到以下错误消息:
> $ dmnpm init
/usr/local/lib/node_modules/dm-npm/index.js:152
co(function*() {
^
SyntaxError: Unexpected token *
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/local/lib/node_modules/dm-npm/bin/dm-npm:3:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
这是由
引起的co(function*() {
var projectName =
yield prompt('project name: '.blue);
process.stdin.pause();
});
#!/usr/bin/env node --harmony
在脚本的顶部对我有用,在你的情况下 /bin/dm-npm