Reputation: 1284
I see a weird situation in my project.
There are 3 packages not listed in package.json
, but installed during the development process.
In my understanding, npm list
should show me extraneous error
. However, no error displayed. I am wondering how npm decides which package is extraneous or not?
The three packages are async
, debug
and mime
. and I am using the npm 1.4.28
Upvotes: 1
Views: 2564
Reputation: 10848
First off, you should update your npm
, since 1.4.28
is quite old; latest is 2.4.1
.
Secondly, a package is only extraneous if it is not a (dependency, devDependency, optionalDependency) named in package.json
or any of its dependencies.
For example, I can create this scenario:
$ mkdir test && cd test
$ echo {} > package.json
$ npm install --save jslint
$ npm install exit
$ npm ls
Now exit
is extraneous, even though it is a dependency of jslint
, because jslint
has its own version of exit
under node_modules/jslint/node_modules/exit
. Let's get rid of that:
$ rm -rf node_modules/jslint/node_module/exit
$ npm ls
Now exit
is no longer extraneous because it is needed to fulfill the dependency of jslint
. But if I look in ./node_modules
I will see two packages, exit
and jslint
, only one of which is named in package.json
.
Please let me know if I have misunderstood your question.
Upvotes: 3
Reputation: 1348
I am wondering how npm decides which package is extraneous or not?
Installed package that is not in package.json will trigger npm extraneous error
.
Try to refresh local node_modules
directory.
Install needed packages with --save
/--save-dev
key.
Upvotes: 0