Cannot start Electron application - missing package.json - npm

I'm currently doing a Python project where I want to display my results in an Electron application. I have seen a demo video on YouTube on how to set up Electron on a Mac. The video showed 3 simple steps to be executed in the terminal:
git clone https://github.com/electron/electron-quick-start
cd electron-quick-start
npm install && npm start
When I first ran the above commands it worked fine for me. I was able to start the Electron application.
But when I tried to re-start the application using the command npm start after going into the electron-quick-start directory, I am not able to open the application.
I am continuously getting an error message as follows:
(base) Viveks-MacBook-Pro:electron-quick-start vivekchowdary$ npm start
npm ERR! path /Users/vivekchowdary/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/Users/vivekchowdary/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/vivekchowdary/.npm/_logs/2019-04-19T12_55_01_157Z-debug.log
(base) Viveks-MacBook-Pro:electron-quick-start vivekchowdary$
I don't know what it means? But I just want to open the Electron application.

As the error message states, the file package.json cannot be found.
One possible reason is that the terminal is not in the correct project folder and that you need to cd into the folder before running npm start.
If you cd to any folder that has no package.json (and whose parent folders don't have a package.json) and run npm start, you'll be presented with this error message.
Your specific file path seems to indicate that you ran npm start from your home folder, not the project folder that contains package.json.

I got a similar issue and I fixed it by creating the files it was asking for as well as a basic package.json file that my compiler generated for me

Related

What is the reason for the npm installation error ENOENT: no such file or directory, open 'C:\Users\tusha\package.json'?

I try to install libraries with npm on Windows to work with JavaScript, but it shows this error output in Windows command prompt window:
C:\Users\tusha>npm install
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\tusha/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\tusha\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\tusha\AppData\Local\npm-cache\_logs\2022-04-24T10_37_38_185Z-debug-0.log
C:\Users\tusha>
Here is also a photo:
Screen shot of command prompt window with the error output
The log of the failed installation process:
The complete log file on Google Drive
ERR telling that in your folder directory you are installing some packages through npm. Look like package.json not found in located directory
Before run npm install to empty folder you have to initialize the npm init to create package.json file. and start installing packages.
npm install reads the file package.json from the current directory and installs all the packages it depends on. The error message says that there is no such file.
You need to cd to the directory the Node.js project (e.g. something you might have checked out from a Git repository) and run npm install there.
Alternatively, if you are trying to install a specific package from the npm repository then you need to:
cd to the directory containing the package you want to add it as a dependency of
run npm install name-of-package
If you don't have a project yet, and want to create one, then:
cd to the directory you want to create your package inside
npm init and follow the prompts
Alternatively, if you are trying to install a program from npm globally then reconsider as current best practice is to run program with npx and not install them as globals. Use the name of the package you want to run as an argument.
npx create-react-app
If you really want to install globally, then use the -g switch and the name of the package.
npm install -g create-react-app

NPM Error code when trying to run npm start

I keep getting the npm ENOENT error when I try to run npm start. I'm not sure what to do to fix this issue.
I have tried to change permissions for folders.
bryantcaruthers-> npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/bryantcaruthers/workshop-vs-code-can-do-that/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/bryantcaruthers/workshop-vs-code-can-do-that/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/bryantcaruthers/.npm/_logs/2019-11-06T03_31_38_233Z-debug.log
Be able to run npm start with no errors.
The error is that there is no package.json file in the directory you are running the code in:
no such file or directory, open /Users/bryantcaruthers/workshop-vs-code-can-do-that/package.json
Are you expecting a package.json file in that directory? Or should you be running npm start from somewhere else?
You can resolve that issue by following methods:
Ensure dependencies described correctly on package.json
Just run
npm install
Check issue still exists. and If issue not resolved, continue these methods.
npm cache clean
sudo npm install -g npm
npm cache clean
npm install
I found solution to this error. This error mostly occurs because you are not working on the right folder, cd to the right folder where you installed the npm or you can open the folder with vs code. For example, you have a main folder that contains the site or app folder, you need to be working from the subfolder and not the main folder, this is where you installed the npm and the dependencies are described correctly on package.json.
Your project workshop-vs-code-can-do-that does not have a packeage.json file available, to create it, go to terminal (on your project path), run this command
npm init -y
Encountered the same error.
Root Cause:
Not installing(npm i) and starting(npm start) from the correct path in terminal
Solution:
Change the directory to the application directory where package.json
present
hope this might help, Thanks.

How can i run a demo React Native Code on Phone

Im totally new to React Native and just learned to setup the necessary environments and follow these steps;
Install Node.js
Download Expo client at mobile device
npm install -g create-react-native-app
cd to my desired directory
create-react-native-app some_app_name
cd to my app folder containing default app.js
npm start
basic / empty app will be loaded on my phone and code can be opened using editor of choice.
Now i've downloaded some demo simple apps from github and udemy (with full source code)
I tried to extract the files and cd to the folder and execute "npm start"
However, there is always this error
react-native-scripts: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! demo_app#0.1.0 start: react-native-scripts start
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the demo_app#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
May i know what is missing? How do i get this right?
The command to run a react-native app is react-native run-android for android devices and react-native run-ios for ios devices. Are you sure that you are running these commands to start the app?
Seems like this might be a duplicate of:
sh: react-scripts: command not found after running npm start

Alternative on "npm run eject"

Will a ReactJS app project be ended when I simply close the CLI, while in first instance the Node.js Package Manager was running the developer server through the "npm start"-command in the CLI? Or will the ReactJS app project run in the background?
If the second question is true, how can I otherwise stop the ReactJS app project without having to worry that I have to run "npm run eject" in the CLI and never being able to run the ReactJS app project in the development stage? The following occurs when I do so (run "npm run eject" in the CLI) for the second time:
npm ERR! path C:\Users\1st assembled M-PC\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\1st assembled M-PC\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\1st assembled M-PC\AppData\Roaming\npm-cache\_logs\2018-04-27T17_27_41_529Z-debug.log
If your app is running simply press Control + C to halt it. Closing the Command Prompt will achieve the same result. You will still be able to run it again with npm run start after this.
A note on ejecting – to successfully eject you need to run npm run eject from your project folder. However this operation is usually needed only if you are a power user and you aren't happy with the default configuration.

After running command "npm i" I started getting multiple error

I am facing this issue after I ran npm i command by following THIS THREAD. Now when I am trying to install various dependency for my project, I am getting bunch of errors:
λ npm install -g
npm WARN
D:\ITC\node_modules\#microsoft\sp-lodash-subset\node_modules\lodash
is not a child of C:\Users\xxxxx\AppData\Roaming\npm
npm ERR! path
D:\ITC\node_modules\#microsoft\sp-lodash-subset\node_modules\lodash
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename
'D:\ITC\node_modules\#microsoft\sp-lodash-subset\node_modules\lodash'
-> 'D:\ITC\node_modules\#microsoft\sp-lodash-subset\node_modules.lodash.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR!
C:\Users\xxxxx\AppData\Roaming\npm-cache_logs\2017-07-26T12_26_10_273Z-debug.log
This is a common issue in the new version of npm. It has been brought to their attention. I believe you can fix the issue by creating a new root directory for your project and paste everything but your node_modules folder in it. Then try npm install
your path might be incorrect...
go to your directory and press right click with shift and select command prompt then execute your command...
I faced the same issue with npm. In my situation I had the project folder on Github. Please delete the local copy of the project folder entirely. Clone the project again to local and run the npm i command inside the project directory.
I am assuming you are trying to install the packages installed in dependencies mentioned in package.json.
I used VSCode in administrator mode,
have windows 10 :build 19041.508 and
Using WSL 2.0.