简体   繁体   English

我可以在没有 npm run 命令的情况下运行 npm 包吗?

[英]Can I run an npm package without the npm run command?

I would like to run the next.js build process directly from the command line without going over the package.json.我想直接从命令行运行 next.js 构建过程,而不需要查看 package.json。 Is it possible to run it without npm run?是否可以在没有 npm run 的情况下运行它?

Instead of running npm run build而不是运行npm run build

I would like to run next build directly on the command line.我想直接在命令行上运行next build

Cheers for the help.为帮助喝彩。

you can go to package.json and then change the scripts.您可以转到 package.json 然后更改脚本。

"build": "next build", “构建”:“下一个构建”,

I figured it out so basically whatever you add at the end of the npm run command gets attached to the npm run command:我想通了,所以基本上你在 npm run 命令末尾添加的任何内容都会附加到 npm run 命令:

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

Now I can run现在我可以跑了

npm export jane-doe-directory

And the application will be exported to that directory.并且应用程序将被导出到该目录。

If you look inside your project's node_modules/.bin directory, you should see an alias for the next command.如果您查看项目的node_modules/.bin目录,您应该会看到next命令的别名。 So if you want to run next build directly without using npm ...所以如果你想直接运行next build而不使用npm ...

Bash:重击:

./node_modules/.bin/next build

Windows Command Prompt: Windows 命令提示符:

.\node_modules\.bin\next.cmd build

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

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