简体   繁体   English

尝试在npm install -g之后运行时没有这样的文件或目录

[英]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) 我正在使用Vagrant运行默认的Linux VM(使用admin privilleges,以便symlink可以工作)

After installing a package with npm install -g <package> , I am unable to run the symlink created (as a shortcut to run from path). 使用npm install -g <package> ,我无法运行创建的符号链接(作为从路径运行的快捷方式)。

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. 直接使用<filename>运行文件不起作用,抛出: No such file or directory ,而使用node <filename>运行它将起作用。

I have tried npm install -g gulp and running gulp works perfectly. 我已经尝试过npm install -g gulp并且运行gulp可以完美地工作。 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? 检查gulp的内容,我发现#!/usr/bin/env node行与此文件完全相同,所以我在这里缺少什么?

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

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

ls -l $(which summon)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 执行npm install -g时会发生什么 - What happen when npm install -g was executed 错误代码尝试安装 Audacity 时未找到文件或目录 - Error code No file or Directory found when trying to install Audacity 即使安装了npm install -g gulp,也没有找到本地gulp安装 - No local gulp install found even after installing npm install -g gulp 尝试在Linux上运行npm run build时,NPM给出ELILIFECYCLE错误 - NPM gives ELILIFECYCLE error when trying to run npm run build on linux 尝试运行 Docker 映像时出现“exec 用户进程导致“没有这样的文件或目录”错误 - Getting "exec user process caused "no such file or directory"" error when trying to run Docker image g ++:没有这样的文件或目录? - g++: No such file or directory? 我想在 npm 上安装 mechanic,我尝试运行这条线 sudo npm install -g mechanic,但它给了我错误,我不明白这个错误 - I want to install mechanic on npm, I tried to run this line sudo npm install -g mechanic, but it gives me error, I don't understand this error 尝试从 Github 安装文件时无法在 debian 上创建目录 - cannot create directory on debian when trying to install files from Github 无法使用 npm install -g 安装turtle-cli - Cannot install turtle-cli with npm install -g 在新文件目录下运行bash脚本? - Run a bash script when new file directory?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM