Node can't see the file in a react project - node.js

I have a React project and I configured a build process in a file named build.js. The file tree is as below:
File structure:
I added "node build.js" script to scripts in package.json. It works fine on MacOS. However when I try to run the same npm run build script in my Windows machine, I get an error which says: "The system cannot find the file specified." "node build.js" command works fine when I move the file outside of project, for example to desktop. However, it does not work in the project.
The error from console:
I searched for any similar problem, but could not find anything. Any help would be appreciated.
edit: I solved my problem. It sees the file but can't see the file which should be removed by script. I misunderstood the problem and this is a false alarm. Sorry.

Related

I've got nodejs installed but trying to run code in the terminal shows error "can't find module"

VScode error message saying shell integration not activated
Judging from your Screenshot:
The javascript file is located at ~/Documents/MY PROJECTS/hello.js.
You are trying to run a hello.js file in ~.
~ would be EDWIN in your case.
Since Node js can't find the hello.js file it throws an error. Locate the correct directory with cd Documents/MY PROJECTS and then try to run the js file via node hello.js

how to fix "Error: Cannot find module '/home/container/index.js'", I've tried everything

So the host that I use for my discord bot died so I downloaded all the code and tried hosting it on my PC. But I get the following error.
Error: Cannot find module '/home/container/index.js
I've tried everything I can:
updated nodejs
reinstalled all my packages
Changed package.json
How can I fix this?
Cannot find module means you are trying to run non-existent file.
Ensure there is index.js in your working directory. If not,
Use cd to go to the directory where it is (usually it's src near the package.json)
Run node ./index.js
Many time people have just the problem of command line to run file,
as windows and linux have
different syntax to run .js file
i.e. node ./index.js for linux
and node .\index.js for windows

Error: Cannot find module 'C:\Users\Elie\Projects\MEAN\task-manager\api\index.js'

I have been following along this youtube playlist: https://www.youtube.com/watch?v=P3R-8jj3S7U. We got to the part where we finished a model and are ready to test. Run nodemoncommand to start the API and I get this error
Here is the file in question as well
Thanks for the help
UPDATE: In the package.json file i changed main to the exact file path of index.js you can see the package.json file here. This seemed to produce a better result but still didnt fix the issue. The error now reads clean - exit waiting for changes before restart and seems like it should be working but it isnt. I attached a sceengrab to have a better look. View Error
UPDATE #2: I changed the main property in the package.json file to app.js and ran nodemon command and produced this error. A bit of progress?
UPDATE #3: Here is my app.js file for reference
UPDATE #4: I updated my express property verision to include an actual verison number then ran npm install which seemed to be sucessful. I then ran nodemon again. Here are the results
Based on the information you've provided, I would guess you are executing nodemon by just typing the nodemon command without any arguments. This only works if your entry point is named index.js, but in the screenshot you provided it's clear that your entry point is named app.js, so you should be running nodemon with the following command:
nodemon app.js

Heroku: npm Failure - index.js not found

I am trying to set up my "web app" on Heroku. When I double click on my index.html it shows up in my browser but the app fails to open in Heroku. I am accessing my files through github, which is working fine.
In oder to set up my working environment I followed this tutorial exactly:
https://www.kirupa.com/react/setting_up_react_environment.htm
After reading about my initial errors in Heroku:
1.) I added the Node Version (But not the npm Version since I only saw how to add one or the other and not both.)
"engines": {
"node": "7.10.0"},
2.) I changed the Script to:
"scripts": {
"start": "node index.js"},
That was straight forward enough, but now after running npm start, I see a distinct error (also reflected in the https://www.npmjs.com browser test):
Error: Cannot find module '/Users/MyUser/MyFolder/index.js'
Now, due to that tutorial above, I only have "index.jsx" located within an additional folder like: MyFolder/dev/index.jsx
I tried to change the file extension in package.json and or the file path, but no matter what I do, the file is not being found. I am guessing that ".jsx" should automatically be recognised as ".js", but I think that only because of the way that the tutorial was written...
Please help me figure out how to run npm start without error.
Thank you in advance!
I am no longer asking this question, although I am still curious about why it didn't work. I mostly just need a set up that WILL work. I am willing to start over from scratch...
I'm in the same boat here. In comparing a working version I had, adding a file called "Procfile" (no extension) then putting in:
web: node index.js
should work.
Read here for more info:
https://devcenter.heroku.com/articles/procfile
Hope it helps! Sorry it's like 7 months late eheh

Node-Webkit: Application not running by drag drop or running from command line

Its my first day with NWjs and I am strugling with it.
I have going through its documentations: documentations
I am following whatever is written over there.
Downlaoded NWjs and extracted it in a folder
Created a sample application
Drag drop the package.json on nw.exe
It should show a window however nothing is happening.
I also tried to run it from command line but that did not work too.
"C:\Users\vikas\Desktop\cromium apps\nwjs.exe" "C:\Users\vikas\Desktop\cromium apps\app\package.json"
Please guide what should I do.
I am using a windows pc and node.js is also installed.
Package.json
{
"name": "helloworld",
"main": "index.html"
}
I found 2 workarounds to run the application but I still do not know why the steps mentioned in documentation did not worked.
So for others I am providing the both workarounds to run the application below:
Create a .zip of your application folder then rename it abc.nw then drag drop it on the nw.exe or run the following command in cmd "path of the nw.exe" "your zip path.nw"
open command line install nodewebkit by using the following command npm install -g nodewebkit (npm must be installed beforehand)
then cd to your application folder and run the follwoing command nodewebkit

Resources