Set up local package dependencies using npm

My current situation involves having an npm dependency installed from a local path, which also has its own dependencies. I have observed that in this scenario, npm simply copies the contents of the local folder into node_modules. Is there any possible way to prompt npm to run npm install on the package folder before copying it over?

Answer №1

npm install /path/to/foo will simply copy the contents from the specified path into your local package's node_modules folder. However, if you were expecting this method to ensure that npm update and npm install would automatically fetch the latest code from that path and update/install the dependencies of the package at that path, then using this approach is incorrect.

In order to achieve these desired outcomes, you should include that local dependency in your package.json's dependencies or devDependencies (a feature supported by npm since version 2.0). Here's an example:

"dependencies": {
  "foo": "file:/path/to/foo"
}

By following the above steps, when you run npm update or npm install, the local dependency will be treated similarly to any other dependency in your project.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Calculating the total of time values using Javascript

I am working with a set of time values stored as JSON data: 14:49:09 00:16:46 00:00:05 My goal is to loop through these times and calculate their sum to obtain the final total time: The resulting time will be 15:06:00 using Javascript. ...

Having difficulty encapsulating three.js rendered particles within a single div

I'm facing an issue where the particles generated by my three.js project are not contained within a specific div or html element as intended. Instead of staying within the designated boundaries, the particles are spreading across the entire DOM witho ...

Is there a way to dynamically alter the background style of a div by clicking on it multiple times using Javascript?

I am attempting to create a calendar where each day changes its background color between blue and green when clicked, using JavaScript and CSS. It should function similar to a toggle feature. The default color is blue, and I have successfully made the days ...

Ways to verify the successful creation of a child process in NodeJS

I am attempting to use Node JS child_process to open a file as shown below var child_process =require('child_process'); var spawn = child_process.spawn; var exePath='<exe's path>' var filePath='<file path>' v ...

Assign the value from JavaScript to the element with the "ng required" attribute, without resetting frm.$error.required to false

My situation involves using a button with ng-style that relies on frm.mybtn.$error.required as follows: ng-style="frm.mybtn.$error.required?{'border-color':'#a94442'}:''" I am updating the value of the button from JavaScript ...

Organizing grid elements within the popper component

I am struggling to align the labels of options in the AutoComplete component with their respective column headers in the popper component: https://i.stack.imgur.com/0VMLe.png const CustomPopper = function (props: PopperProps) { co ...

What are the steps to launch an express-generator built application in production mode?

When using the Express application generator, the recommended way to start the server is as follows: $ DEBUG=myapp:* npm start Executing this command successfully launches the app and starts listening on the specified port. However, the presence of DEBU ...

I encountered an issue with npm run build when attempting to launch a react application on Firebase, resulting in an error

npm ERR! code ENOENT npm ERR! syscall open npm ERR! path C:\Users\Myname\Desktop\god\package.json npm ERR! errno -4058 npm ERR! enoent ENOENT: file 'C:\Users\Myname\Desktop\god\package.json' not f ...

Is there a way for me to set up a confirmation pop-up alert before hitting the submit

I am interested in implementing a pop-up alert that asks "Are you sure you want to delete this comment?" when a user clicks on a button. How can I achieve this? $('button').on('click', function(){ // Display an alert to the user c ...

Switch out external CSS stylesheets automatically using toggle scripting

Hello there! I've been trying to figure out a way for this script to switch back to the original CSS external stylesheet. Here is the code that I currently have: $(document).ready(function() { $("#css-master2").click(function() { $("link[title=chang ...

I am facing an issue with the Tailwind Flowbite Datepicker dropdown UI when running "npm run prod" for minification. The class is not being added during minification on the npm

I have successfully integrated a Laravel project with Tailwind CSS. I have also implemented the Flowbite Datepicker using a CDN to include the necessary JavaScript. Initially, everything was working fine and the date-picker was displaying correctly. Howev ...

What is the best way to rotate points around a mesh?

I am attempting to utilize Three.js to create a collection of points using Three.Points. My goal is to have these points rotate around a single point or mesh. I have already successfully generated the points randomly within a cylinder region, following the ...

Using JavaScript parameters in a HTML document

I am trying to replicate a page similar to this. The issue I am facing is the inability to use external JS files in ASP.net (as far as I know). Therefore, I am defining the functions and attempting to utilize them within the HTML page instead. <%@ P ...

How can I implement a Component to show the details of a blog post when clicked in Next.js?

Can someone help me figure out how to display individual blog post details in a modal when clicked on in a blog website, where the posts are stored in a Component rather than pages? The file structure is set up like this: Component |_ Posts.js |_ PostDet ...

Embracing Asynchronous Header Management in Ember.js

I am facing an issue where I need to asynchronously insert the headers into the adapter. The token function is responsible for checking if the token has expired, refreshing it via Ajax if needed, and then returning the new token. However, it appears that ...

How can you refresh a functional component using a class method when the props are updated?

I've created a validator class for <input> elements with private variables error, showMessage, and methods validate and isOk. The goal is to be able to call the isOk function from anywhere. To achieve this, I designed a custom functional compone ...

What could be causing the appearance of a mysterious grey box hovering in the upper left portion of my image and why is the code only adjusting the size of the grey box instead of the entire

I've been working on embedding some JavaScript into my Showit website to create a drag-and-drop feature that displays a collage/mood board effect. Everything is functioning correctly, but I'm running into issues with resizing the images. There&a ...

Managing the closure of a Chrome packaged application

Is there a way to execute code before a Chrome packaged app closes? I have tried the following methods without success: chrome.app.window.current().onClosed chrome.runtime.onSuspend window unload event For instance: chrome.runtime.onSuspend.addListene ...

Gradual disappearance of preloader as the page loads

I'm facing an issue with setting a gif as a website preloader. Despite trying different JavaScript solutions, the preloader remains visible even after the page has finished loading. $(window).on("load", function() { $(".loading").fadeOut("slow"); ...

When embedding HTML inside an Angular 2 component, it does not render properly

Currently, I am utilizing a service to dynamically alter the content within my header based on the specific page being visited. However, I have encountered an issue where any HTML code placed within my component does not render in the browser as expected ( ...