Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extraneous Package when Installed Locally

I was trying to install phantomjs in order to make test Twitter Bootstrap. After I had installed it locally i.e. npm install phantomjs, it reported that the package was extraneous.

├─┬ [email protected] extraneous │ ├── [email protected] ... npm ERR! extraneous: [email protected] /Users/admin/bootstrap/node_modules/phantomjs npm ERR! not ok code 0 

However, when phantomjs was installed globally i.e. npm install phantomjs -g, it worked fine i.e. no extraneous error reported.

Questions:

  1. Is it because phantomjs not specified in the package.json file?
  2. General question: Can we have any package e.g. phantomjs installed globally and also locally?
like image 615
moey Avatar asked Apr 27 '13 13:04

moey


People also ask

What is extraneous package?

Extraneous packages are those present in the node_modules folder that are not listed as any package's dependency list. If the --production flag is specified or the NODE_ENV environment variable is set to production , this command will remove the packages specified in your devDependencies .

How do you fix npm err extraneous?

To resolve extraneous errors in the npm list output, you need to add the packages in your package. json file. Once the upgrade is done, run the npm list command again to see if the extraneous error is still there. Then run the npm install command to install the dependencies again.

What is the difference between global installation and local installation of dependencies?

Installing the local dependencies means the module will be available only for a project you installed in the same directory. Global installing dependencies puts the module into your Node.

What does npm prune -- production do?

Description. This command removes "extraneous" packages. If a package name is provided, then only packages matching one of the supplied names are removed.


1 Answers

  1. Yes. (Re-installing with npm install wont install phantom.js again.) (Btw.: npm install xxx --save will automatically add xxx to the package.json)
  2. Yes. Local package versions are preferred over global ones. (Although you need some path handling for executables.)
like image 200
TheHippo Avatar answered Oct 03 '22 02:10

TheHippo