Parallelshell module not running on npm. What can be done? - node.js

This is package.joson file's scripts my onchange and parallelshell modules are totally updated.
```
"scripts": {
"start": "npm run watch:all",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server",
"scss": "node-sass -o css/ css/",
"watch:scss": "onchange \"css/*.scss\" -- npm run scss",
"watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\""
},
```
If you want to run the code on MAC or linux replace /" with single
quote(').
An error comees up like this when I run this code.
Please provide me a solution.

Just change the version of parallelshell to 3.0.1
To do that run this commands on cmd:
npm uninstall parallelshell
npm install --save-dev parallelshell#3.01

Related

React App's npm i is Hanging on Installation

So, I've tried running npm i on my React app so that I can work concurrently on both front and back end at the same time. However, it seems to be hanging on the "install":
appName#0.1.0 install
cd server && npm i && cd ../client && npm i
Below are the package.json scripts I'm using:
"scripts": {
"start": "node server/server.js",
"dev": "concurrently \"cd server && npm run watch\" \"cd client && npm start\"",
"install": "cd server && npm i && cd ../client && npm i",
"build": "cd client && npm run build",
"seed": "cd server && npm run seed",
"test": "echo \"Error: no test specified.\" && exit 1",
"eject": "react-scripts eject"
},
What am I doing wrong? Any help is greatly appreciated!
You may be running into an infinite loop since you have defined an install script in your package.json. For more details on npm scripts configuration have a look here.
You might also be facing similar issues with some of the other scripts you have defined, e.g. build also calls itself npm run build. You should build the project code as part of the build script. See the CRA source build script for reference: https://github.com/facebook/create-react-app/blob/d960b9e38c062584ff6cfb1a70e1512509a966e7/package.json#L8
Try removing the install script and run the commands manually when you need to install dependencies for your project. The updated scripts:
"scripts": {
"start": "node server/server.js",
"dev": "concurrently \"cd server && npm run watch\" \"cd client && npm start",
"build": "cd client && npm run build",
"seed": "cd server && npm run seed",
"test": "echo \"Error: no test specified\" && exit 1",
"eject": "react-scripts eject"
},
As a side note/question, why don't you run npm i from the root of the project and then run your build and seed commands?
Only installing dependencies will not build your app, in most cases.

Custom script in NPM package.json is ignored, runs as standalone

in my package.json I have these scripts:
"scripts":
{
"lint": "./node_modules/.bin/eslint src",
"build": "npm run clean && npm run dev && npm run prod",
"tsc": "./node_modules/.bin/tsc",
"dev": "./node_modules/.bin/webpack --config webpack.dev.js",
"prod": "./node_modules/.bin/webpack --config webpack.prod.js",
"clean": "del /q inet-henge*.js* dist",
"watch": "./node_modules/.bin/webpack --config webpack.dev.js --watch",
"postinstall": "copy inet-henge.js \"..\\flask\\customer_topology\\static\""
}
But for some reason postinstall is completely ignored when i run npm run build. When I run it as standalone script, it runs, the file is copied to the new location. Path is correct. What could be the problem, I am on Windows
post<x> runs after <x> so postinstall runs after install and if you want a script to run after build it should be called postbuild See https://docs.npmjs.com/cli/v6/using-npm/scripts for more details.

Start react-create-app and Electron.js with one NPM command

I have simple custom starter pack react-create-app and Electron.js.
I have added to package.json file:
"scripts": {
"electron": "electron .",
"start": "cross-env BROWSER=none react-scripts start",
....
and I can start Electron with npm run electron and React with - npm start.
What I want is to start React and Electron just with one command like: npm run both.
I have tried:
"both": "\"npm start\" \"npm run electron \"",
but I am getting an error in a log file:
Exit status 1 node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
- nothing specific
I have tried and:
"start": "npm run electron . && cross-env BROWSER=none react-scripts start",
, but this starts the Electron, when I close it, it start the React app.
Again error:
"electron": "electron .",
"start": "cross-env BROWSER=none react-scripts start",
"both": "\"npm run electron\" \"npm run start\"",
I don't know, how to start react-create-app and Electron with just one NPM command ?
Consider utilizing concurrently.
cd to your project directory and run the following command to install it:
npm i -D concurrently
Then redefine the both script in the scripts section of your package.json as follows:
"both": "concurrently \"npm start\" \"npm run electron\""
or the slightly shortened equivalent:
"both": "concurrently \"npm:start\" \"npm:electron\""

NPM command for run Node server after webpack finish building

I want to run a command like: npm run start:dev to make my node server runs but after webpack finished building bundles.
My current npm scripts are:
"scripts": {
"start": "node server/server.js",
"start:dev": "npm run build:prod & npm start",
"lint": "eslint *",
"build:dev": "webpack",
"build:prod": "webpack -p --env production",
"dev-server": "webpack-dev-server",
"test": "cross-env NODE_ENV=test jest --config=jest.config.json"
},
The current command will kick both operations together.
Typo: you don't actually want to use &, you want &&:
"start:dev": "npm run build:prod && npm start",
A single ampersand will background the run:build job and cause start to run concurrently.

Cannot resolve module index.js npm package

I am trying to test a NPM package in my local (my own package). I followed this guide : http://rajasekarm.com/publishing-react-component-npm/
I have this in my package.json:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "./node_modules/.bin/babel statbox.js -o index.js",
"prepublish": "npm run build"
},
I committed this custom package in my git, and did an
npm install 'url/url/my_sample.git' --save
But when I do a:
import myModule from 'my_sample'
It says that index.js is unresolved. How do I solve this one?
If there's no index.js file, I suppose you don't have built (because npm build will translate your statbox.js to a index.js).
So run npm build and retest your package.

Resources