我正在尝试发布npm包,当我全局安装包并尝试运行cli命令时出现此错误:
/.nvm/versions/node/v0.12.2/bin/myPack: line 1: use strict: command not found
/.nvm/versions/node/v0.12.2/bin/myPack: line 3: syntax error near unexpected token `('
/.nvm/versions/node/v0.12.2/bin/myPack: line 3: `var _commandLineArgs = require('command-line-args');'
错误引用的文件顶部:
'use strict';
var _commandLineArgs = require('command-line-args');
var _commandLineArgs2 = _interopRequireDefault(_commandLineArgs);
package.json bin部分:
"bin": {
"myPack": "dist/myPack.js"
}
当我在本地开发中运行时,这很有效,有什么问题?
答案 0 :(得分:48)