This is my package.json
for the module that I'm including in the parent project:
{
"version": "0.0.1",
"name": "module-name",
"dependencies": {
"express": "3.3.4",
"grunt": "0.4.1",
"grunt-contrib-compass": "0.4.0",
"grunt-contrib-copy": "0.4.1",
"grunt-contrib-cssmin": "0.4.1",
"grunt-contrib-jshint": "0.6.3",
"grunt-contrib-requirejs": "0.4.1",
"grunt-contrib-uglify": "0.2.2",
"grunt-contrib-watch": "0.5.1",
"grunt-express-server": "0.4.1",
"grunt-karma": "0.4.5",
"grunt-regex-replace": "0.2.5",
"request": "2.25.0"
},
"scripts": {
"postinstall": "grunt install"
}
}
One thing to note is that this module is contained in a private repo and I include it in the parent package.json
like: "module-name": "git+ssh://git@myserver:user/module-name.git"
This question is related to
npm
You might need to install the grunt-cli, try this before doing a npm install:
sudo npm install -g grunt-cli
That fixes the grunt does not exit for me, you'll also need a valid grunt file.
Also check that your package name is correctly accepted:
{
"name":"My Awesome Package"
}
{
"name": "my-awesome-package-name"
}
OP may be true for an older version of node. However, I faced the same with node 4.4.1 as well.
It very well may be linked to the node version you are using. Try to upgrade to a latest version. Certain dependencies don't load transitively if they are incompatible with node version.
I found this by running npm update
.
After upgrading to latest version (4.4 -> 5.9); this got fixed.
I am using windows machine.
In my case it helped to remove node_modules
and package-lock.json
.
After that just reinstall everything with npm install
.
I had the same problem. But on the same machine one project had good package.json, where all my dependencies are successfully installed. And in another project my package.json dependencies were not installed no matter what i do. I just copied the package.json and pasted into that another project. And it worked! The difference i have found was only empty line at the start of file. Dont know or it influences anything, maybe some other problem. But the problem was only the package.json file.
Another way to work this around is to add this into your module package.json
scripts section
"preinstall": "npm install {Packages You depend on}"
what this will does is, it will install all packages needed by the module and you won't get that error.
if you inherited this code, it could be that the dependencies and versions were locked and you have a ./npm-shrinkwrap.json file.
if your dependency is not listed in that file, it will never get installed with the npm install
command.
you will need to manually install the packages and then run npm shrinkwrap
to update the shrinkwrap file.
I had very similar issue, removing entire node_modules
folder and re-installing worked for me. Learned this trick from the IT Crowd show!
rm -rf node_modules
npm install
Just in case anyone is suffering from this predicament and happens to make the same asanine mistake that I did, here is what it was in my case. After banging my head against the wall for an hour, I realized that I had my json incorrectly nested, and the key "dependencies" was inside of the key "repository".
Needless to say, no errors were evident, and no modules were installed.
I think that I also faced this problem, and the best solution I found was to look at my console and figure out the error that was being thrown. So, I read it carefully and found that the problem was that I didn't specify my repo, description, and valid name in my package.json
. I added those pieces of information and everything was okay.
I suspect you're facing the issue where your package.json
file is not in the same directory as your Gruntfile.js
. When you run your grunt xxx
commands, you get error an message like:
Local Npm module "xxx" not found. Is it installed?
For now, the solution is:
npm install
to load them locallyIMHO, it is sad that we cannot have grunt resolve modules loaded from a parent npm module (i.e. package.json in a parent directory within the same project). The discussion here seems to indicate that it was done to avoid loading "global" modules but I think what we want is loading from "my project" modules instead.
I was receiving this error when I installed a clean Node dev environment on windows.
To fix this, I went into my new project directory (that I just scaffolded with yo angular
) and typed in two commands:
npm install -g grunt --save-dev
That will install the local grunt dependencies to your project. Next:
npm install
That will ensure all your (new) project dependencies are installed.
Tada!
Worth to mention to make sure your dependencies should be in the dependencies
part of your package.json
(as opposed to devDependencies
).
My issue was basically the same as OP:
repo1
) via "module-name": "git+ssh://git@myserver:user/my-repo-name.git"
in other repo(Let's call it repo2
), repo2
's node_modules
, one package dependency from repo1
wasn't there.repo1
was listing that dependency in devDependencies
instead of dependencies
repo1
's package.json
from devDependencies
to dependencies
repo2
, I removed my node_modules
and package-lock.json
, did npm install
, an voilĂ !... dependency was there!happens with old node version. use latest version of node like this:
$ nvm use 8.0
$ rm -rf node_modules
$ npm install
$ npm i somemodule
edit: also make sure you save
.
eg: npm install yourmoduleName --save
Source: Stackoverflow.com