Reputation: 53809
I basically have a completely empty folder that has one file, test.js
. I wanted to install a couple of modules, but when I try doing something like npm install express
I get an error that says I have no package.json
file.
$ npm install express
> [email protected] install /Users/me/node_modules/node-icu-charset-detector
> node-gyp rebuild
CXX(target) Release/obj.target/node-icu-charset-detector/node-icu-charset-detector.o
../node-icu-charset-detector.cpp:7:10: fatal error:
'unicode/ucsdet.h' file not found
#include <unicode/ucsdet.h>
^
1 error generated.
make: *** [Release/obj.target/node-icu-charset-detector/node-icu-charset-detector.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.0.0
gyp ERR! command "/usr/local/Cellar/node/5.1.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/me/node_modules/node-icu-charset-detector
gyp ERR! node -v v5.1.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: `node-gyp rebuild`
npm WARN install:[email protected] Exit status 1
/Users/me
├── [email protected]
├── UNMET PEER DEPENDENCY react@>=0.14.0 <0.15.0
└── UNMET PEER DEPENDENCY react-dom@>=0.14.0 <0.15.0
npm WARN ENOENT ENOENT: no such file or directory, open '/Users/me/package.json'
npm WARN EPEERINVALID [email protected] requires a peer of mongodb@~1.4 but none was installed.
npm WARN EPEERINVALID [email protected] requires a peer of react@>=0.14.0 <0.15.0 but none was installed.
npm WARN EPEERINVALID [email protected] requires a peer of react-dom@>=0.14.0 <0.15.0 but none was installed.
npm WARN EPEERINVALID [email protected] requires a peer of react@^0.14.0 but none was installed.
npm WARN EPACKAGEJSON me No description
npm WARN EPACKAGEJSON me No repository field.
npm WARN EPACKAGEJSON me No README data
npm WARN EPACKAGEJSON me No license field.
Upvotes: 2
Views: 3697
Reputation: 1249
Heads up: If you are using scoped packages Scoped Packages I am afraid it is.
Upvotes: 0
Reputation: 2343
No it is not required to have package.json.
You can have number of different module names in it which modules you want to install on hit of npm install.
You can have better control over versions of modules
You can separate modules like dependencies and dev-dependencies
For you 'npm install express' will install express module for you.
Upvotes: 0
Reputation: 126215
There are basically three main forms of npm install
:
npm install
: read the package.json
, and install everything from it into this directory.npm install express
: install express into this directory.npm install --save express
: install express into this directory, and save it into the package.json.The second form doesn't require a package.json
to exist here:
$ npm install express
[email protected] node_modules/express
├── [email protected]
├── [email protected]
...
If you get an error message, something else is wrong.
Upvotes: 1