我可以 运行 没有 npm 运行 命令的 npm 包吗?

Can I run an npm package without the npm run command?

我想 运行 直接从命令行 next.js 构建过程,而不需要经过 package.json。没有 npm 运行 可以 运行 吗?

代替运行宁npm run build

我想直接在命令行运行next build

干杯帮助。

您可以转到 package.json 然后更改脚本。

"构建": "下一个构建",

我想通了所以基本上你在 npm 运行 命令末尾添加的任何内容都会附加到 npm 运行 命令:

"scripts": {
    "dev": "next dev",
    "build": "next build",
    "export": "next build && next export -o",
  }

现在我可以运行

npm export jane-doe-directory

然后应用程序将导出到该目录。

如果您查看项目的 node_modules/.bin 目录,您应该会看到 next 命令的别名。所以如果你想直接 运行 next build 而不用 npm...

Bash:

./node_modules/.bin/next build

Windows 命令提示符:

.\node_modules\.bin\next.cmd build