It does add only when I execute: npm install <package_name> --save
In the documentation though: https://docs.npmjs.com/cli/install is written this:
By default, npm install will install all modules listed as dependencies in package.json.
Which is misleading.
npm install without arguments installs all dependencies (and dev dependencies) listed in the package.json file.
npm install --production installs all the dependencies (but no dev dependency)
npm install <package> installs a package and its dependencies.
npm install <package> --save installs a package and its dependencies, and adds it in the package.json file.
Edit: Since npm 5, --save is implied.
No, it's not. I think you are misreading the sentence.
npm install without any package name (as in your quote) will install all dependencies mentioned in the package.json.
Crete package.json file in your application folder.
Exp:- var/www/html/node/rest/package.json
{
"name": "node-api",
"main": "server.js",
"version": "0.0.1",
"dependencies": {
"express": "~4.0.0",
"mongoose": "~3.6.13",
"body-parser": "~1.0.1",
"mysql": "^2.5.4"
}
}
Then run npm install command your application folder
Exp:- var/www/html/node/rest npm install
You could run npm init again to update the dependencies info.
Related
ng build gives an error that
Unable to Find npm install -g #angular/cli#latest in devDependencies.
To start application using npm start, but when I try to build a file it is Giving me an error Message in CMD:
Unable to find "#angular/cli" in devDependencies. Please take the
following steps to avoid issues: "npm install --save-dev
#angular/cli#latest" Versions of #angular/compiler-cli and typescript
could not be determined. The most common reason for this is a broken
npm install. Please make sure your package.json contains both
#angular/compiler-cli and typescript in devDependencies, then delete
node_modules and package-lock.json (if you have one) and run npm
install again.
I follow all the step as it suggest me in Error message, but still it is giving me same message enter image description here
I had the same issue following steps helped me to resolve it,
Update package json
from
"angular-cli": "anything"
to
"#angular/cli": "1.0.4"
Deleted node_modules and installed node modules again with
npm install
Change angular-cli.json for
from
"environments": {
"source": "environments/environment.ts"
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
to
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
It seems that you have a problem with your node_modules. Delete the node_modules and package-lock.json and be sure you have all the dependencies in your package.json. After that run npm install
Another point could be that you don't have installed the #angular/cli module.
Like in the error message said, try to install this package with npm install -g #angular/cli.
I have npm-5.3.0 installed on my arch Linux.
I create a new project with npm init and fill in the details. This creates a package.json file with the details.
After that when I do npm install <package> --save, the file package.json does not change, and there is no entry for dependencies in the file. I had installed the package globally previously if that matters.
I found that the --save does not work with global and I had global=true set in the .npmrc file.
Setting global=false in the file fixed it.
Check update is available
npm i -g npm-check-updates
npm-check-updates -u
npm install
you have to change
"dependencies": {
"express": "",
"mongodb": "",
"underscore": "",
"rjs": "",
"jade": "",
"async": ""
}
then run
npm update --save
ı have solved adding npm 'FIRST' module from to dependencies manuelly in package.js this problem. Next, you can try npm install moduleName --save
I'd like to install npm modules based on package.json
I'd like to know if there is anyway to automate installing modules.
For instance dependencies of package.json is as follows.
"dependencies": {
"express": "3.1.0",
"jade": "*",
"stylus": "*",
"mongodb": ">= 0.9.6-7"
}
do I have to install modules one by one like this?
npm install express#3.1.0
npm install mongodb#0.9.6
and etc.
Any help would be appreciate.
See the documentation about npm install.
By default, npm install will install all modules listed as dependencies in package.json.
So you can just type npm install.
when you are installing first time use --save, that module installation info will be added to package json
after that at new location you just need to run npm install
npm install express#3.1.0 --save
npm install mongodb#0.9.6 --save
npm install
also refer link
You can do this by typing:
sudo apt-get update
sudo apt-get install npm
use nvm to switch versions.
If you want to install a specific version of module you should use
npm install module_name#version --save
--save add's the module and the version of the module to your package.json file's dependencies. If you want to install just any version of a module you can use
npm install module_name --save
if you don't use --save at the and node would still install the last version of the module you want but it wouldn't add it to your package.json file . In this case you have some specific versions of some modules in your package.json file if you want to install them, you can simply use the
npm install
command. npm install installs all modules in your package.json file.
Also if you are new in nodeJs you can check this out. I hope this helps. Have a good day good sir.
You could install modules written in package.json as follows.
npm install
I have run into some issues in installing the grunt related node module dependencies for my project,
I want to install the selected dependencies using one command, so I used below,
npm install grunt grunt-contrib-jshint grunt-cli grunt-contrib-watch grunt-exec grunt-contrib-symlink grunt-contrib-clean grunt-contrib-copy grunt-text-replace grunt-git --save-dev
Got error like 'grunt-exec#0.4.6 requires a peer of grunt#~0.4 but none was installed.'
So as per the feedback from googling, found we can hardcode the dependency version like below fix,
npm install grunt#~0.4 grunt-contrib-jshint grunt-cli grunt-contrib-watch grunt-exec grunt-contrib-symlink grunt-contrib-clean grunt-contrib-copy grunt-text-replace grunt-git --save-dev
It has temporarily fixed the issue for sometime but now I get an error like
'grunt-git#1.0.0 requires a peer of grunt#~1.0.1 but none was installed.'
So it seems that the grunt plugins needs different version of same dependency - grunt(in my case). Installing the plugins one by one instead of a cluster also wont resolve the issue
Update
Since people want to take points away from this answer w/o reading the comments to see that a solution was found, here's what we arrived at:
An instance like this, you should review the previously released versions for grunt-git, find an older version that meets your reqs (v0.3.8) and double check if the features you want to use with the plugin are available or not. If it is, try npm install grunt-git#0.3.8 --save-dev. Releases can be found here.
Original Solution
First you'll want to initialize your project by creating a package.json file by running the command npm init. You'll be prompted to answer several questions, you can change the default values if you like.
Once the project has been initialized, install the dependencies one at a time & include the flag --save or --save-dev. This will add the dependency to the package.json manifest. Example: npm install grunt-contrib-jshint --save-dev
Once you have all of your dependencies listed in your package.json file, you can then achieve a one-command install using npm install.
The NPM registry has a very detailed article on using package.json if you'd like to learn more.
install grunt with the global flag
npm install -g grunt
I have fixed my issue using the suggestions from theaccordance.
Only the recent version of grunt-git(1.0.0) was having the dependency issue, so I am installing the previous version 0.3.7 which doesn't require a particular version of grunt.
npm install grunt#0.4.5 grunt-contrib-jshint grunt-cli grunt-contrib-watch grunt-exec grunt-contrib-symlink grunt-contrib-clean grunt-contrib-copy grunt-text-replace grunt-git#0.3.7 --save-dev
I encountered a similar issue today when trying to install grunt-exec.
npm ERR! peerinvalid The package grunt#1.0.1 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer grunt-exec#0.4.6 wants grunt#~0.4
From some clues in this thread I fixed it by...
npm uninstall grunt
at the root folder of my project, and I edited package.json to remove grunt from the devDependencies.
I already had grunt installed globally, so didn't need it in the project too.
Running
npm install -D grunt-exec
a second time worked for me and my updated devDependencies now looks like this:
"devDependencies": {
"chai": "^3.5.0",
"grunt": "^0.4.5",
"grunt-contrib-clean": ">0.4.0",
"grunt-contrib-concat": "^1.0.0",
"grunt-contrib-jshint": "~1.0.0",
"grunt-contrib-uglify": "^1.0.1",
"grunt-exec": "^0.4.6",
"grunt-mocha-test": "^0.12.7",
"mocha": "^2.4.5"
},
with the new lines being grunt, and grunt-exec.
So far my project works as it did before adding grunt-exec. It looks like I just found a simple way to downgrade to an earlier version of grunt.
Here's the version info from the global install:
>grunt -V
grunt-cli v1.2.0
grunt v0.4.5
Hope this helps.
Say I have "karma": "~0.12.0" in package.json, and the latest version of karma is 0.13.19. Will npm install -g karma look in the local package.json or will it install the latest version of karma available in npm?
Once you provide npm with a package name, it will not look for in the package.json file.
If you want specific version, you can provide it in the command, not in the package.json:
npm install -g karma#0.12.0