#WHERE NPM INSTALL MODULES HOW TO#So maybe the problem is that npm install has a different behavior when first installing a local module and includes each dependecies, but references them as bundled in the package-lock.Offline_boltQuick Start Introduction to Node.js A brief history of Node.js How to install Node.js How much JavaScript do you need to know to use Node.js? Differences between Node.js and the Browser So next time npm install runs and fines the package-lock.json it, sees the bundled flag and does not install the dependencies of the localModule. But at the same time it creates a package-lock.json that references the dependencies of the localModule with the bundled set to true. The thing is that the first time (without package-lock) npm install is run in the projectA folder, it correctly installs the dependencies of localModule in its local node_modules folder. I think I have narrowed down the cause of this trouble. I have to delete the package-lock.json and try again for it to work. Now everything works.but if I have to delete the node_modules of projectA, or localModule's and re-install (keeping the package-lock), the install fails. However no package-lock.json is created in the localModule directory. Also dependecies of localModule are installed locally in node_modules folder of localModule. When I run npm install in the projectA folder with npm 5.0.4 the first time, a package-lock.json is created in the project folder, and a symlink in the node_modules folder to the localModule. ProjectA has in its package.json a saved dependency of localModule in a dynamic link created with: npm install -S. I develop using Vagrant on OS X or Linux.I don't use a proxy, but have limited or unreliable internet access.I use a proxy when downloading Git repos.I use a proxy to connect to the npm registry.Also require the local_module in a main_project file. #WHERE NPM INSTALL MODULES CODE#It should either install all dependencies in the local_module locally since it is in an other scope with the main_project and modules cannot be shared, or copy the whole module as it used to for prior npm versions How can the CLI team reproduce the problem?Ĭreate the structure I showed above and try to load the shared module inside some code in local module. This probably happens because nodejs require uses the realpath to look for files which means it follows the symlink to local_module and then looks for its dependencies locally instead of starting the search from main_projects node_modules where the link is located and the common dependency is installed. So when the code executes that requires the local_module, which in turn requires moduleA, it will fail because it cannot find moduleA in its node_modules root since it is installed in the main_project root and cannot be retrieved. However this is not happenning! What happens is that inside local_module the moduleB is installed but moduleA is not installed because it is found in main_project's dependencies, and a link from node_modules of main project is installed to local_module. This leaves the impression that since local_module is not in the project root, its dependencies will be separately installed in it's folder. If sits inside the root of your project, its dependencies may be hoisted to the toplevel node_modules as they would for other types of dependencies. Its dependencies will be installed before it's linked. Install the package in the directory as a symlink in the current project. local_module or by including it in the package.json along the main project's other dependencies and issuing a plain npm install, a problematic installation takes place. When you are in the project root and try to install the local_module either through npm install. To describe the exact structure of the project, let's say we have the following modules and their dependencies:Īs you can see the main project and the local_module share the moduleA dependency. When you have a project and need to install a module from a local folder outside of the project root and also one of the local module's dependencies is also included in the project's dependencies, npm messes the dependency installation. Other ( see below for feature requests):.npm is doing something I don't understand.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |