npm init
to create the package.json file and then you use
ls node_modules/ | xargs npm install --save
to fill in the modules you have in the node_modules folder.
Edit: @paldepind pointed out that the second command is redundant because npm init
now automatically adds what you have in your node_modules/ folder. I don't know if this has always been the case, but now at least, it works without the second command.