2017-04-26 84 views
2

我在通过ConEmu运行鱼壳的Windows上。鱼在默认情况下不承认“& &”运营商有这个然而运行npm脚本时,哪个shell npm正在使用?

"scripts": { 
    "test": "echo 'a' && echo 'b'" 
} 

并运行“故宫运行测试”工作。 所以,我想这一定是使用默认的“CMD”,这是什么但是说npm config ls -l | grep shell,... 当我改变“测试”脚本:

"scripts": { 
    "test": "echo 'a' && ls" 
} 

这也适用,而显然不支持ls在“cmd”中。

这到底是怎么回事?

回答

0

我不知道在你的情况下使用了什么shell,也不知道检查哪个shell是npm使用的首选方法,但是我有一些一般提示,这可能有所帮助。

您可以尝试

{ 
    "scripts": { 
    "test": "echo $0" 
    } 
} 

能产生类似的结果:

$ npm run test 

> @ test /home/matmat/test 
> echo $0 

sh 

(在Linux上的bash)

C:\Users\qbolec\Documents\test>npm run test 

> @ test C:\Users\qbolec\Documents\test 
> echo $0 

$0 

在Windows上的Node.js命令提示符。

您也可以尝试

"test": "which ls" 

得到一些更多的信息。

0

显示行npm run将命令发送到sh外壳,该外壳通常指向默认的Bourne兼容外壳。我没有使用模拟器的经验,但我敢打赌它在你的环境中使用bash(因为Fish不是Bourne兼容的)。