想自己搭一个前端脚手架,将代码上传到了github上,使用download-git-repo来下载,但是上传至npm之后,下载下来运行init报错
: line 1: syntax error near unexpected token `('
line 1: `const program = require('commander');'
但是代码里面没有使用中文字符,没有多加括号
代码如下
const program = require('commander');
const download = require('download-git-repo');
const chalk = require('chalk');
const ora = require('ora');
program
.version('0.1.0')
.option('-i, init combuild-cli', 'init combuild-cli')
.parse(process.argv);
if (program.init) {
const spinner = ora('正在从github下载x-build').start();
download('direct:xxx', program.init, function(err) {
if (!err) {
// 可以输出一些项目成功的信息
console.info(chalk.blueBright('下载成功'));
} else {
// 可以输出一些项目失败的信息
}
})
}
package.json
"bin": {
"combuild-cli": "./bin/com-build.js"
},
这是官方的api,感觉也没啥问题
请问有大神知道是哪里写的不对吗,本机运行版本
node:v9.10.0
npm:5.6.0
你的包叫啥名字
在文件第一行添加