Is it possible to run npm scripts directly?

There is a script in my package.json file

"start": "cross-env NODE_ENV=development PORT=3000 CODE_SPLIT=0 node ./react-imvc/bin/www-babel-register",

I need to run the script with the --inspect flag, but I am unable to modify the package.json. I would like to update the script to include the --inspect flag as follows:

"start": "cross-env NODE_ENV=development PORT=3000 CODE_SPLIT=0 node --inspect ./react-imvc/bin/www-babel-register"

Instead of modifying the package.json directly, I want to achieve this by running the script through npm using the command:

npm run "cross-env NODE_ENV=development PORT=3000 CODE_SPLIT=0 node --inspect ./react-imvc/bin/www-babel-register"

I tried running the script using npm run script, but it did not work as expected.

Can anyone guide me on how to run an npm script in the desired way as mentioned above?

Answer №1

If you need to execute a script with the argument --inspect without modifying the package.json:

npm run start -- --inspect

Refer to:

$ npm run --help
npm run-script <command> [-- <args>...]

alias: run

Answer №2

So you're ready to run the script in your package.json, which should be structured like this (don't forget to include the --inspect flag):

"scripts": {
  "start": "cross-env NODE_ENV=development PORT=3000 CODE_SPLIT=0 node --inspect ./react-imvc/bin/www-babel-register"
} 

To execute this script, simply enter npm run start. You can add additional scripts under a different key for easy access with `npm run '.

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

Enhance the functionality of the 'validate as true' function

I have an object that resembles the following $scope.object = { Title: 'A title', Status: 'Open', Responsible: 'John Doe', Author: 'Jane Doe', Description: 'lorem ipsum dolor sit' } My aim now i ...

The transmission of ContentType is unsuccessful

I'm having an issue with the code in my app. It seems that the content-type is not being sent. Is there a way to force it to be sent? $.ajax({ crossDomain: true, type: ...

``Do not forget to close the modal window by clicking outside of it or

I am looking for a way to close the modal window either when a user clicks outside of it or presses the escape key on the keyboard. Despite searching through numerous posts on SO regarding this issue, I have been unable to find a solution that works with ...

Issue with Angular 17 button click functionality not functioning as expected

Having trouble with a button that should trigger the function fun(). Here's the code snippet I'm using. In my TS file: fun(): void { this.test = 'You are my hero!'; alert('hello') } Here is the respective HTML: &l ...

What strategies can be employed to mitigate the activation of the losing arm in a Promise.race?

My current task involves sending the same query to multiple identical endpoints (about five) across various Kubernetes clusters. The goal is to aggregate the results without any delays and report failures to the user while continuing with the process seaml ...

Using JavaScript's indexOf method with multiple search values

I have a data set that includes various duplicate values ["test234", "test9495", "test234", "test93992", "test234"] I am looking to find the positions of every instance of test234 in the dataset Although ...

How can we programmatically add click handlers in Vue.js?

Currently attempting to add some computed methods to an element based on mobile viewports exclusively. Here is a simplified version of my current project: <a class="nav-link float-left p-x-y-16" v-bind:class={active:isCurrentTopicId(t.id)} @click="onTo ...

The resizing of the window does not trigger any changes in the jQuery functions

Here is a snippet of jQuery code that executes one function when the window size is large (>=1024) and another when it is resized to be small. Although the console.logs behave as expected on resize, the functions themselves do not change. This means th ...

How can I use npm link to link a module with a custom main file, not named index.js?

I am facing an issue with my node module that has "main": "dist/index.js" in the package.json. When I run node my-package from the parent folder, it successfully executes dist/index.js as the entry file. However, after running npm link, a progress bar ap ...

Guide on how to activate a hyperlink with a specified target using JavaScript

I have a URL structured like this: <a id="preview" ng-href="/preview/{{accountId}}/app/{{app.id}}" target="preview" class="btn btn-default" style="margin-left: 20px;" ng-hide="isJobMode">Preview</a> This is part of an Angular app, and I am tr ...

Tips for transforming an Observable stream into an Observable Array

My goal is to fetch a list of dogs from a database and return it as an Observable<Dog[]>. However, whenever I attempt to convert the incoming stream to an array by using toArray() or any other method, no data is returned when calling the retrieveDo ...

In JavaScript, using window["functionName"](arguments) will result in a TypeError message saying that the function does not exist

When trying to execute an AJAX function based on the active tab in my application, everything works smoothly when I trigger the function after specific events. However, I encounter difficulties when attempting to call the function using a dynamically gener ...

Encountering a Bad Request Response When Trying to Access WCF Service via Jquery Ajax

Encountered an issue when trying to call a WCF web service using jQuery Ajax, resulting in a bad request error without clear insight into the root cause. The service is not triggering any methods - neither success nor failure. Both the web service and the ...

Encountering a frozen screen while attempting to create or initiate a new reactjs project with create-react-app

I encounter the following issue: Attempting to start a new React application in D:\project Packages are being installed. Please be patient as this could take some time. Installing react, react-dom, and react-scripts... The process appears to stall a ...

Conflict between jquery and hoverIntent libraries

I've encountered an issue with a website that was functioning properly until we added a new form to a specific page. The form, created by another person, utilizes javascript/jQuery for processing. Since adding this form, it has caused the majority of ...

Automatically populating state and city fields with zip code information

Starting out in the world of web development, I encountered a challenge with a registration form I'm constructing for our company. For guidance, I referred to this resource: http://css-tricks.com/using-ziptastic/. This project marks my initial interac ...

Using the .load() function to import an HTML file from the directory above

I am trying to achieve the following structure: folder1 index folder2 page to load Can I dynamically load the 'page to load' in a div within the 'index' page using DIV.load()? I have attempted various paths (../folder2/page, ./, ...

Utilizing setState within the useEffect hook can lead to the application experiencing

Why does my code result in an endless loop error? This issue is pointing to the line marked with *: function Blog() { const [blog, setBlog] = useState({}); const query = useQuery(); async function fetchBlog(query) { const data = awai ...

Error encountered while running "ionic cordova run android" command

Recently, I revisited my Ionic Cordova app after a few months and encountered an unexpected dependency issue when attempting to make a minor adjustment to the app. Although the app previously functioned correctly, even reverting all changes failed to addre ...

SwitchBase is undergoing a transformation where its unchecked state goes from uncontrolled to controlled. It is important to note that elements should not transition back and forth between un

There is a MUI checkbox I am using: <Checkbox checked={rowValues[row.id]} onChange={() => { const temp = { ...rowValues, [row.id]: !rowValues[row.id] }; setRowValues(temp); }} in ...