windows 10 error -> '.' is not recognized as an internal or external command - reactjs

I am trying to run 'npm run build' in the terminal of parser written in React. But whenever I do this I get an error inline
> matrix#1.0.0 build E:\work\Parser\parser
> ./node_modules/webpack-cli/bin/cli.js --mode=development
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! matrix#1.0.0 build: `./node_modules/webpack-cli/bin/cli.js --mode=development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the matrix#1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\criti\AppData\Roaming\npm-cache\_logs\2019-12-18T08_21_16_082Z-debug.log
This happens only in windows.
When i searched for the
./node_modules/webpack-cli/bin/cli.js --mode=development
in package.json I found this to be written as
"build": "./node_modules/webpack-cli/bin/cli.js --mode=development",
"build:dev": "./node_modules/webpack-cli/bin/cli.js --mode=developement",
"build:prod": "./node_modules/webpack-cli/bin/cli.js --mode=production",
"build:watch": "./node_modules/webpack-cli/bin/cli.js --watch",
"build-server": "./node_modules/webpack-cli/bin/cli.js ./parser.js -o ./parser_server.bundle.js --target='node'",
What is this issue ?

You don't need to put ./node_modules/webpack-cli/bin/ on each command, simply put webpack --mode development.

Assuming you have npx installed, try this in the command line: npx webpack --mode=development

Related

How can I disable npm run build errors?

I currently have an interesting error with npm run build and I don't know what's wrong. Is there a way to run the build with errors?
$ npm run build
> todoo#0.1.0 build D:\FitnessTracker
> tslint -p tslint.json && ./node_modules/.bin/tsc
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todoo#0.1.0 build: `tslint -p tslint.json && ./node_modules/.bin/tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todoo#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\raul.gimcojocaru\AppData\Roaming\npm-cache\_logs\2020-02-11T13_25_39_104Z-debug.log```
That project seems to expect an UNIX-style shell and you're on Windows.
You could try replacing the build script entry with just
"build": "tsc"
but there's no guarantees things will still work.

How to set React app variables in NPM start script

so the npm start in my package.json looks like this
"start": "REACT_APP_Environment=development react-scripts start",
This worked fine for previous developers on the project, possibly because they were on MacOS, that's not the case for me on windows, when I run I get
> REACT_APP_Environment=development react-scripts start
'REACT_APP_Environment' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! enterprise#0.1.0 start: `REACT_APP_Environment=development react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the enterprise#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Omar\AppData\Roaming\npm-cache\_logs\2019-09-22T15_12_59_217Z-debug.log
I can fix this by removing the environment variable from the start script and running by the command set "REACT_APP_Environment=development" && npm start, but this is not convenient, how can I have it all included and work properly on windows in my start script? thanks
I would recommend checking out .env, seems like it might solve your problem
npmjs.com/package/dotenv

Why I get an error when I try to deploy a react app to GitHub Pages?

I tried to deploy a react app to GitHub pages...
Commands on package.json:
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
and received this error:
The "file" argument must be of type string. Received type undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app#0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
It was supposed to deploy.
I've resolved mine. Newer version 2.1 has some issue. Revert back to 2.0.1.
Reinstall Github pages with a specific version:
npm uninstall gh-pages
npm i gh-pages#2.0.1
npm run deploy // as usual
Hope that helped. :)

npm start gives error `webpack-dev-server: not found` even if it is installed

In package.json devDependencies I have webpack-dev-server installed:
"webpack-dev-server": "3.2.1"
but when I run the start script, which looks as follows:
"start": "webpack-dev-server --inline --config demo/webpack.config.js --port 9000 --mode development"
I get this error:
sh: 1: webpack-dev-server: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! your-app#2.0.5 start: `webpack-dev-server --inline --config demo/webpack.config.js --port 9000 --mode development`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the your-app#2.0.5 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
What is the issue here?
Notice that every script you want access in cli, script should be install in your system as globally.
you can install globally every script you want with npm. that way add -g in your command when you want install package.
In your case, you should run this command:
npm install webpack-dev-server -g
after that you can access webpack-dev-server in your command. like your code webpack-dev-server added to start script in your package.json file.
After that, you can run npm install webpack-dev-server --save-dev command to add this package in your node_modules.
Now, you have access webpack-dev-server in your cli. As you write in your start script in your package.json.
My app by default, did a "production" install, which didn't install devDepencies.
I did:
export NODE_ENV=development
before executing npm install and it installed dev dependecies, so now it works.

Got error running existing react js app

I am facing this error while running react js app. I already install current version of node js and npm.
~/Desktop/music/client
$ npm start
client#1.0.0 start C:\Users\DIU\Desktop\music\client
./node_modules/webpack-dev-server/bin/webpack-dev-server.js --hot --progress --colors --inline --quiet --history-api-fallback
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start"
npm ERR! node v7.5.0
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! client#1.0.0 start: ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --hot --progress --colors --inline --quiet --history-api-fallback
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client#1.0.0 start script './node_modules/webpack-dev-server/bin/webpack-dev-server.js --hot --progress --colors --inline --quiet --history-api-fallback'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the client package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --hot --progress --colors --inline --quiet --history-api-fallback
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs client
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls client
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\DIU\Desktop\music\client\npm-debug.log
This worked for me:
ctrl + Alt + Delete,
Task Manager,
Find all running instances of node server and kill them.
install your packages.
basic idea is that your node server keeps running in the background even after you think you've closed it in the console and it is accessing all your node files.

Resources