npm can't find package.json
I think, npm init
will create your missing package.json
file. It works for me for the same case.
Update 2021
npm init
Please refer to Deepali's answer for details.
Original Outdated Answer
I think you forgot to setup the directory for express:
express <yourdirectory>
Once you do that you should be able to see a bunch of files, you should then run the command:
npm install -d
Regards.
I'll be brief but deadly. :) install -d will not work for you. It's simple. Try
$ npm install -g express
Follwing the below steps you well get package.json file.
npm --version
npm install express
npm init -y
If Googling "no such file or directory package.json" sent you here, then you might be using a very old version of Node.js
The following page has good instructions of how to easily install the latest stable on many Operating systems and distros:
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager