我正在构建一个npm库并将其发布到npm。 发布后我试图全局安装库。 但它不起作用,看起来它正试图直接打开文件
我的package.json如下所示:
{
"name": "lssomename",
"version": "1.0.4",
"description": "Test",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"run": "node index.js"
},
"author": "Test",
"license": "ISC",
"dependencies": {
"command-line-args": "^5.0.2",
"fs": "0.0.1-security",
"ncp": "^2.0.0",
"rimraf": "^2.6.2",
"zip-folder": "^1.0.0"
}
}
一旦我尝试运行它就会引发以下错误
/home/thabung/.nvm/versions/node/v8.5.0/bin/lssomename: line 1: $'\r': command not found
/home/thabung/.nvm/versions/node/v8.5.0/bin/lssomename: line 2: syntax error near unexpected token `('
'home/thabung/.nvm/versions/node/v8.5.0/bin/lssomename: line 2: `const log = require("./logger");
如果尝试直接运行index.js
文件,则会出现同样的错误,这意味着
当我尝试
./index.js
而不是
node index.js
答案 0 :(得分:0)