gpt4 book ai didi

node.js - cross-env 命令在 nodejs 中如何工作?

转载 作者:行者123 更新时间:2023-12-05 05:55:13 25 4
gpt4 key购买 nike

我的 package.json 中有以下行

"scripts": {
"start": "cross-env NODE_ENV=development node index.js"
}

我可以看到“yarn start”命令运行正常,但是当我运行直接在终端中执行“cross-env NODE_ENV=development node index.js”命令,出现以下错误:

zsh: command not found: cross-env

如果 cross-env 未在终端中注册,“yarn start”命令如何工作?

最佳答案

https://docs.npmjs.com/cli/v7/configuring-npm/folders#executables

When in local mode, executables are linked into ./node_modules/.bin so that they can be made available to scripts run through npm. (For example, so that a test runner will be in the path when you run npm test.)

这只是一项让事情变得更简单的功能。这也意味着,如果您正在与多人一起工作一个项目,您只需 npm install --save 一个模块——您不必担心项目中的每个人都在全局手动安装它.如果你想在命令行上自己运行它,你可以:

  • 全局安装模块
  • 在命令行中手动输入./node_modules/.bin/cross-env

关于node.js - cross-env 命令在 nodejs 中如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69483812/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com