How can I find the package.json for npm that lists all globally installed packages? I know I can find the root with npm root -g, but I cannot find the package.json in that directory.
If you run npm list inside the node_modules directory, it will list all the globally installed modules.
Related
I was using bower in my project for dependency management. But now I wanted to move to node and npm. But the problem is few of my dependencies are not node modules like Smooth-Div-Scroll1 and swiftype-search-jquery2
How to manage all those dependencies in my node project. When I tried doing
"swiftype-search-jquery": "git#github.com:swiftype/swiftype-search-jquery.git",
"smooth-div-scroll": "git#github.com:tkahn/Smooth-Div-Scroll.git",
it is not able to download dependency and throw error
npm ERR! code ENOPACKAGEJSON npm ERR! package.json Non-registry package missing package.json: swiftype-search-jquery#git+ssh://git#github.com/swiftype/swiftype-search-jquery.git. npm ERR! package.json npm can't find a package.json file in your current directory.
These dependencies don't have package.json in their folder.
I don't think it's possible.
Here is a guide to migrate from bower to npm, it's pretty easy.
https://codecraft.tv/courses/angularjs-migration/step-2-typescript-and-webpack/converting-bower-to-npm/
Yup, It is not possible with NPM but at the same time, it is possible with Yarn without making any change. Instead of "npm install" we have to use "yarn install" .
Add dependencies with git url which is not present with NPM .
I manually changed my dependencies in package-lock.json and package.json files. How do I now apply those changes to my node-modules without updating/touching other dependencies?
Run command
npm i
or
npm install --save
npm i command will install all your dependencies into your local machine which are available in the file.
PS: It is not recommended approach to directly update package.json file, always install package using command npm i packageName --save or npm i packageName --save --dev. This will install as well as Update your package.json file too.
I am working on a npm module with a couple dependencies. Now, should i publish the dependencies along with my product via the node_modules folder or not?
No you should not.
You should list all your dependencies in your package.json and publish that.
Your node_modules folder is automatically created when doing an npm install of the module, or npm install in a directory with a package.json.
when I run npm install all of the dependencies will not load in their own folder but instead install them in my node_modules folder so I end up with 50 or so folders. Is there a way to get dependency packages node_modules to stay within that dependencies folder?
Is the structure of dependencies in node_modules simply a mirror of the dependency tree structure found in package.json? Or does performing npm install download what is in package.json and organize node_modules in some special way?
Ideally package.json will correspond to node_modules. Running npm install (with no arguments) will install all the packages described in package.json into node_modules, but running npm install somepackage won't modify package.json unless you use the --save option.
You can also use npm list to check if your node_modules and package.json are in sync. Packages in package.json that aren't in node_modules are tagged UNMET DEPENDENCY, whereas packages in node_modules but not in package.json are tagged extraneous.
Also note that the root package.json doesn't contain the full dependency tree; it only contains the list of direct dependencies. Dependencies of dependencies are listed in the package.json files of the dependencies themselves, recursively.