上QQ阅读APP看书,第一时间看更新
Getting ready
NPM expects to find a package.json file at the root of your project folder. This is a configuration file that describes the details of your project, such as its dependencies, the name of the project, and the author of the project.
Before you're able to install any packages in your project, you must create a package.json file. These are the steps you will usually take to create a project:
- Create a new project folder in your preferred location and either name it mern-cookbook or give it another name of your choice.
- Open a new Terminal.
- Change the current directory to the new folder you just created. This is usually done with the cd command in your Terminal.
- Run npm init to create a new package.json file, following the steps displayed in the Terminal.
After that, you should have a package.json file that will look something like the following:
{ "name": "mern-cookbook", "version": "1.0.0", "description": "mern cookbook recipes", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Eddy Wilson", "license": "MIT" }
After this, you will be able to use NPM to install new packages for your project.