简体   繁体   中英

No such file or directory when trying to run after npm install -g

I am using Vagrant to run the default linux VM (with admin privilleges so that symlink works)

After installing a package with npm install -g <package> , I am unable to run the symlink created (as a shortcut to run from path).

The file contents as follows:

#!/usr/bin/env node
var arguments = process.argv.slice(2);
var fs = require('fs');
var usage = fs.readFileSync(__dirname + '/usage.txt').toString();

if (arguments.length < 3) {
    console.error(usage);
    return;
}

var summon = require('./Summoner');

summon(arguments[0], arguments[1], arguments[2]);

Running the file with <filename> directly doesn't work, throwing : No such file or directory , whereas running it with node <filename> will work.

I have tried npm install -g gulp and running gulp works perfectly. Checking the contents of gulp , I see that the #!/usr/bin/env node line is exactly the same as this file, so what am I missing here?

检查节点可执行文件是否在/ usr / bin / env中

检查已为您安装的模块创建的符号链接,以及该符号链接是否可由用户执行。

ls -l $(which summon)

由于我的Node项目的bin/script具有CR+LF行尾而不是仅Linux LF仅行尾,因此我遇到了这个问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM