npm start does not work for ract template project - reactjs

Running npm start after npm init does not work due to reported missing react-script library.
It is on my Windows 10 machine; I tried uninstalling and reinstalling node but it did not help.
I can only run my project by typing
>node .\node_modules\react-scripts\bin\react-scripts.js start
otherwise if I run:
>npm start
I can see errors pasted below.
reactapptest#0.1.0 start C:(...)\reactapptest
react-scripts start
npm ERR! file bash
npm ERR! path bash
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn bash
npm ERR! reactapptest#0.1.0 start: react-scripts start
npm ERR! spawn bash ENOENT
npm ERR!
npm ERR! Failed at the reactapptest#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
It looks like something is wrong with my path but I am not sure and I do not know how to solve it.

The specific error you are getting points out that bash is not available. Now bash is a shell for Unix and Unix-like environments, it is not typically installed on Windows by default. (Though it is available for Windows as well through MinGW.)
You are working on Windows, you should not need bash with react-scripts. Try upgrading npm with npm install -g npm#latest to see if this is caused by an old and broken version of npm on your system.
EDIT: Also, you may have previously configured npm to use bash. See: how to set shell for npm run-scripts in windows and note that you are pretty much trying to do the opposite, so if you have custom configuration you might want to try removing it (also explained in the linked accepted answer).

Related

Reactnative Fusionchart fc-build-assets shows an error

When I run npm run build:assets it output below error:
sh: fc-build-assets: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
My Package.json is configured as below:
"build:assets": "fc-build-assets --fc-template ./assets/fusioncharts-tpl-ios.html --fc-library ./assets/fusioncharts"
Note. I'm working on a version upgrade of react-native-fusioncharts from 4.1.2 to 5.0.0. Since I couldn't find proper upgrade guide, I follow this one.
https://www.fusioncharts.com/dev/getting-started/react-native/your-first-chart-using-react-native
Edit: fc-build-assets is no longer required in react-native-fusioncharts: 5.0.0 so if you are upgrade it no need to worry about it.

sysmlink error when installing tensorflow/tfjs-node

I'm trying to install #tensorflow/tfjs-node#3.2.1 (latest).
I have follow a lot of other questions I saw regarding such problems but haven't found an answer for this specific issue.
I have installed visual studio with the requested build tools.
node 14.15.5
Tried with and without the flag.
This is the output of the install command:
$ npm install #tensorflow/tfjs-node --build-from-source
npm WARN deprecated node-pre-gyp#0.14.0: Please upgrade to #mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the #mapbox scoped package will recieve updates in the future
> #tensorflow/tfjs-node#3.2.0 install C:\Users\dark_\Desktop\projects\tfjs2\node_modules\#tensorflow\tfjs-node
> node scripts/install.js
CPU-windows-3.2.0.zip
* Downloading libtensorflow
* Building TensorFlow Node.js bindings
symlink ./lib/napi-v7 failed: null
npm WARN tfjs2#1.0.0 No description
npm WARN tfjs2#1.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! #tensorflow/tfjs-node#3.2.0 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the #tensorflow/tfjs-node#3.2.0 install 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\dark_\AppData\Roaming\npm-cache\_logs\2021-02-27T18_14_41_492Z-debug.log
After spening a day trying the usual suspects (node-gyp reinstall as global, windows building tools (re)install as global, parameter settings, etc) I've debugged the install script and found an error in it: after the symlink stuff, the author didn't check the "error" variable, and went straight to process.exit(1)
After I tore out my hair, I've found that the solution is on it's way:
https://github.com/tensorflow/tfjs/commit/2e745c8b6efe5ffc396a86cfc50347e629091248
It has been commited to the main branch (2021.02.26), so probably we'll see it in v3.3.0, or v3.2.x
Now the problem is, that if you just do a simple npm install #tensorflow\tfjs-node, the installer sees it as an error, and deletes the whole downloaded directory in node_modules. You COULD prevent the whole thing by:
EXECUTING npm install #tensorflow/tfjs-node --ignore-scripts
THEN correcting the error by hand in the install script (check the commit at the above link) and
RUNNING npm rebuild #tensorflow/tfjs-node --build-from-source.
I needed to restart VSCode, because it had difficulties picking up the references. But if you don't want to mess arround, go back to the v2.x branch for the time being.

lwc-services is not recognized as an internal or external command

I am trying to run a hellow world app in LWC open source and after "npx create-lwc-app my-app" when I cd in the dir and run "npm run watch" I get the below error.
E:\Development\LWC\workspace\dev>npm run watch
> dev#0.0.0 watch E:\Development\LWC\workspace\dev
> lwc-services watch
'lwc-services' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! dev#0.0.0 watch: `lwc-services watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the dev#0.0.0 watch 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\ABC\AppData\Roaming\npm-cache\_logs\2019-12-24T16_31_47_970Z-debug.log
Have tried to install "npm install --global --production windows-build-tools" again, trierd to manually install npm i lwc-services -g but it has an error 'rollup-plugin2.02 is dprecated update your dependency' but I donot know if that is the issue here , reistalled the nmp but still not working.
You may try running 'npm run watch' after 'npm i' command.
The same issue has been asked here
I was instructed to do npm install -g lwc-services. There were several warnings, including "deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies."
That one seemed more serious than all the others, so I did npm install chokidar. That came in without any problems. Then I retried the previous command. I don't know if the Chokidar was such a big problem, but at least I was able to do the basic exercises and catch up with the rest of the class.

create-react-app running issue even after just created it

*npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! github#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the github#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:*
or sometimes I am different kind of errors just after creating the app. which means no modifications to the default automatic generated project.
and I managed to solved it.
the issue seems to be with my Yarn. incomplete uninstall or something like that. can't solve it by just reinstalling Yarn or uninstall it again. because of that, NPM create-react-app also create bugs, which IDK how.
but the solution is amazing, I just created the project in a different folder. trust me I'm not lying , different location do works in NPM. so I believe I need to format my computer to solve this 100%.
The cause maybe due to I have installed create-react-app via NPM globally and tries to install Yarn create-react-app.
anyway, by using a different folder location, my issue was fixed completely.

npm won't create a symlink for webdriver-manager while using JHipster DevBox

I'm trying to use JHipster with the DevBox at work, so with a proxy.
I think I have everything configured accordingly, but I still can't use JHipster properly.
I want to generate a microservice gateway with Protractor, but when I use yo jhipster or npm install, it gives me the following error:
> example-gateway#0.0.0 postinstall /home/vagrant/workspace/example/example-gateway
> webdriver-manager update
sh: 1: webdriver-manager: not found
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents#1.0.12
npm ERR! Linux 3.13.0-88-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v4.4.5
npm ERR! npm v3.9.6
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! example-gateway#0.0.0 postinstall: `webdriver-manager update`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the example-gateway#0.0.0 postinstall script 'webdriver-manager update'.
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 example-gateway package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webdriver-manager update
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs example-gateway
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls example-gateway
npm ERR! There is likely additional logging output above.
And with sudo:
npm WARN lifecycle example-gateway#0.0.0~postinstall: cannot run in wd %s %s (wd=%s) example-gateway#0.0.0 webdriver-manager update /home/vagrant/workspace/example/example-gateway
However, I found webdriver-manager in the node_modules/protractor/bin directory, but npm seems to be unable to use it.
Actually, I already succeeded once in generating a microservice gateway with Protractor, but I don't know how: the error about webdriver-manager just disappeared one day. Indeed, there was several other errors (packages that didn't want to be installed), and running npm install over and over again while sometimes installing manually some packages seemed to fix them. However I'm trying to use JHipster on another computer so I need to know how to fix the webdriver-manager error.
I took a look in the node_modules folder of the completed gateway project, and discovered a webdriver-manager symlink inside .bin that wasn't in the same directory of the incomplete gateway project, so I supposed npm used it instead of the one in the node_modules/protractor/bin directory. I created one linking the two in the node_modules/.bin directory of the incomplete gateway project with ln -s ../protractor/bin/webdriver-manager webdriver-manager, and it apparently worked.
The problem is that I'm trying to make the installation and the configuration of the JHipster DevBox somehow automated, so people at work wanting to use it don't have to do it manually. If they have to remember to create a symlink each time they encounter that error, it won't be very practical.
Do you know why npm won't create that symlink himself (or sometime fails to install some packages), and how to fix it in a "clean" way?
Ok I found a solution, but I still don't know exactly why it does this and if their is a cleaner way to fix it.
http://perrymitchell.net/article/npm-symlinks-through-vagrant-windows/
I just replaced the node_modules directory by a symlink to somewhere inside the guest machine, so not in the shared folder with Windows. That way, I skip all the problems caused by Windows. The downside is I have to create the link before generating any project, and to fix that link and download again all the dependencies each time I update the DevBox, because I need to destroy the DevBox to update it.

Resources