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

The issue with the max-height transition not functioning properly arises when there are dynamic changes to the max-height

document.querySelectorAll('.sidebarCategory').forEach(el =>{ el.addEventListener('click', e =>{ let sub = el.nextElementSibling if(sub.style.maxHeight){ el.classList.remove('opened&apos ...

What is the best way to utilize node-sass in a complex and deeply nested directory system?

When it comes to using node-sass from the command line, the documentation can be quite basic. Personally, I am looking into utilizing NPM Scripts as my build tool. In my project, I have various components organized by feature, each in its own folder. Thes ...

What is the best way to include a title and a close button at the top of a menu, before the first item, when a button menu is clicked in material-ui?

One of the challenges I'm facing is adding a title to an icon button menu that contains a checkbox list of menu items. When the user clicks on the icon and opens the dropdown, I want the title to appear at the top of the dropdown along with a close bu ...

Steps to address vulnerabilities in @vue/cli

I am currently working on a vuejs-3 project and aiming for 0 vulnerabilities. However, upon running npm install, I encounter 48 vulnerabilities with the current version of node and npm. Even after trying npm audit fix --force, the issue persists. Can anyon ...

methods for pausing music through a toggle button in a React JS application

I am facing an issue with the following shortcode for playing a song on a toggle button. The problem occurs when I try to pause the music and it does not stop as expected. import { React, useState } from 'react'; import './audio.css&apos ...

Implementing a document update event using jQuery

On my WordPress site, I am using a responsive lightbox plugin. When an image is clicked, it opens a popup box with the ID fullResImage. Now, I would like to incorporate the Pinch Zoomer function to it. Do I need to bind a function for this, or is there a s ...

Why is 'this.contains' not recognized as a function when I invoke it within another function?

While attempting to create a Graph and incorporating one method at a time, I encountered an issue. Specifically, after calling a.contains("cats"), I received the error '//TypeError: Cannot read property 'length' of undefined'. Could thi ...

Is it possible to configure Lambda NodeJS 12.x flags (like --experimental-modules) when using AWS SAM local start-api?

When setting up my nodejs server, I chose to use ES6 module syntax: package.json "type": "module" So far, running my server locally as a nodejs process has been successful. For example: "scripts": { "dev": "npm outdated ; nodemon --experimental-modul ...

Next.js is failing to infer types from getServerSideProps to NextPage

It seems like the data type specified in getServerSideProps is not being correctly passed to the page. Here is the defined model: export type TypeUser = { _id?: Types.ObjectId; name: string; email: string; image: string; emailVerified: null; p ...

Utilizing v-if and splice on users to select items from v-model

After following a tutorial, I have the code snippet below that I would like to enhance: <div style="margin-top: 10px;"> v-for="task in taskItems" :key="task.id" <q-icon :name="task.icon"/> <div ...

Struggling to get my package to install globally using npm install -g

I have been working on implementing CLI functionality into my npm package called intercept-proxy. Despite lacking clear documentation, I managed to piece together the necessary steps by referencing and modifying code from express.js. To enable CLI usage, ...

I am only able to trigger my AJAX request once

Whenever I click on a checkbox, an ajax function is triggered. This function sends a query string to a PHP script and returns relevant HTML. Strangely enough, if I first select a dropdown option and then check another checkbox along with the previous one ...

Obtain the data of the highlighted row in a telerik grid directly from the client side

I am attempting to retrieve the value of a GridBoundColumn with DataField="id" using JavaScript on the client side. When the user clicks on the image button within a row, I need to extract the id for that specific row and then invoke a web method by passin ...

Exploring the intersection of JavaScript and PostgreSQL: Leveraging timezones and timestamps

I'm a bit confused about how to properly use timestamps. For example, when a user creates an article, they can choose a PublishDate, and the system also automatically stores a CreateDate. a. Should I make both PublishDate and CreateDate timestamps wi ...

I am experiencing issues with datejs not functioning properly on Chrome browser

I encountered an issue while trying to use datejs in Chrome as it doesn't seem to work properly. Is there a workaround for this problem if I still want to utilize this library? If not, can anyone recommend an excellent alternative date library that ...

Setting up Node.js 10 and npm on an Alpine Linux system

I am currently using Alpine to construct my Rails application and I am encountering complications with some of its dependencies. At this moment, here is my Dockerfile configuration: FROM ruby:2.5.1-alpine ENV BUNDLER_VERSION=2.0.2 RUN apk add --update - ...

What steps can be taken to resolve an npm/yarn start problem?

yarn run v1.22.10 $ react-scripts start node:internal/modules/cjs/loader:488 throw e; ^ Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: The subpath './lib/tokenize' in the package is not defined by "exports" in /home/victor/Desktop/epitech/te ...

Click on the link within the Checkbox label on MUI

I am working on creating a checkbox for the "Terms of Use," using FormControlLabel to nest a Checkbox. However, I also need to include a link that opens a Dialog component displaying the terms. The challenge is that clicking on the link checks the checkbox ...

The toLowerCase method seems to be malfunctioning along with several other functions

JS var score = 0 var yes = "yes" var pokemonName = []; var bg = []; var index = 0; document.getElementById('repete').style.visibility = 'hidden'; (function asyncLoop() { background = bg[num = Math.floor(Math.random() ...

What is the best way to populate empty dates within an array of objects using TypeScript or JavaScript?

I am trying to populate this object with dates from today until the next 7 days. Below is my initial object: let obj = { "sessions": [{ "date": "15-05-2021" }, { "date": "16-05-2021" }, { "date": "18-05-2021" }] } The desired ...