Linux command
npm-init 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Initialize new project
npm init
Initialize with defaults
npm init -y
Create with initializer
npm init [initializer]
Create React app
npm init react-app [my-app]
Create Vite project
npm init vite@latest [my-app]
Set default author
npm config set init-author-name "[name]"
说明
npm init creates a new package.json file. Without an initializer, it prompts for package details. With an initializer, it runs that package's setup process. Initializers like "react-app" are shorthand for "create-react-app".
参数
- -y, --yes
- Accept all defaults.
- --scope _scope_
- Create scoped package.
- -w, --workspace
- Create workspace.
- initializer
- Package to run (create-*).
FAQ
What is the npm-init command used for?
npm init creates a new package.json file. Without an initializer, it prompts for package details. With an initializer, it runs that package's setup process. Initializers like "react-app" are shorthand for "create-react-app".
How do I run a basic npm-init example?
Run `npm init` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -y, --yes do in npm-init?
Accept all defaults.