This is a followup question to my earlier question (but is an independent question)
I am trying to install react and react-dom on a Mac:
npm install --save react react-dom
but get the following warnings (path names replaced with ...
):
npm WARN saveError ENOENT: no such file or directory, open '/Users/../Z/package.json'
/Users/.../Z
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ └── [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]
└── [email protected]
npm WARN enoent ENOENT: no such file or directory, open '/Users/.../Z/package.json'
npm WARN Z No description
npm WARN Z No repository field.
npm WARN Z No README data
npm WARN Z No license field.
I searched around a bit but did not find a good reason for these warnings. SO posts like these seem to suggest installing react in the same directory where node modules are installed. My node is installed in usr/local/bin
but package.json
does not appear anywhere on the machine even on a global search. I just installed npm before trying to install react so don't think its a versioning issue.
If this is a brand new project, it can be resolved by running
npm init
from the root directory of your project (where you wantpackage.json
to be created), and press "ENTER" at all of the prompts to accept the default answers. (It is easy to change your responses by directly modifying thepackage.json
file later.)Once the
package.json
has been created, you will be able to runnpm install
commands!