Felix Fong
Felix Fong

Reputation: 985

Install NodeJS package locally

When i try to install package on my local directory using npm install connect,but it just keep pop up some warning about

no such file or directory, open '/Users/felixfong/package.json'

But i don't not want to install package at my computer directory,i want to install at my local web app directory

Upvotes: 0

Views: 2548

Answers (3)

Pankaj Jatav
Pankaj Jatav

Reputation: 2184

You have to go inside your project directory using Then you can check package.json. If package.json file is not there then initialize npm using the following command:

npm init

Then your can install the package using the following command:

npm install connect

'npm install connect' does not save the connect npm package in package.json file.

For saving the package into package.json file you have to givt --save option like:

npm install connect --save

Upvotes: 2

Adil
Adil

Reputation: 22371

Make sure that you are in web app's directory. Current path can be checked via command pwd in Linux and cd in windows. Navigate to your web app directory if you are somewhere else. Check existence of package.json by listing the content of the folder. ls and dir can be used for ubuntu and windows respectively for listing content. Commands for ubuntu are as below:

pwd    
cd your-path/
ls

Now Initialize npm in your web app directory if package.json is not already existing there.

npm init

This will ask some information like:

  • name of the app,
  • its version,
  • description,
  • entry point,
  • test command,
  • git repo,
  • keywords,
  • author and
  • license (if any)

You can select default values by leaving the fields empty if you aren't sure or confused about any field. Combining this information as json, npm will create a file named package.json

Just run the desired command now after initialization of npm or if its already initialized:

npm install connect

Upvotes: 0

ryder
ryder

Reputation: 897

Are you sure you are inside your local web app directory when you run the npm install connect command?

cd app-directory/
npm install connect

Also ensure that a package.json file is also present in the app-directory.

If it isn't present, you can use npm init command to create the package.json file interactively.

Upvotes: 4

Related Questions