In my app.js,
const app = require("express")();
const port = 3000;
app.get("/", (req, res) => {
res.send("hello world");
});
app.listen(port, () => {
console.log("server running!");
});
This error generated after I save / update the app.js file,
(node:4196) UnhandledPromiseRejectionWarning: Error: Command failed: wmic process where (ParentProcessId=5740) get ProcessId 2> nul
at checkExecSyncError (child_process.js:630:11)
at execSync (child_process.js:666:15)
at kill (C:\Users\SANTOSH\Desktop\nodesql\node_modules\nodemon\lib\monitor\run.js:337:26)
at Function.run.kill (C:\Users\SANTOSH\Desktop\nodesql\node_modules\nodemon\lib\monitor\run.js:425:7)
at Bus.<anonymous> (C:\Users\SANTOSH\Desktop\nodesql\node_modules\nodemon\lib\monitor\run.js:495:7)
at Bus.emit (events.js:327:22)
at restartBus (C:\Users\SANTOSH\Desktop\nodesql\node_modules\nodemon\lib\monitor\watch.js:228:7)
at FSWatcher.filterAndRestart (C:\Users\SANTOSH\Desktop\nodesql\node_modules\nodemon\lib\monitor\watch.js:212:16)
at FSWatcher.emit (events.js:315:20)
at FSWatcher.emitWithAll (C:\Users\SANTOSH\Desktop\nodesql\node_modules\chokidar\index.js:540:8)
(node:4196) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
Package.json file,
{
"name": "nodesql",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "nodemon app.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1",
"mysql2": "^2.2.5",
"sequelize": "^6.6.4",
"sequelize-cli": "^6.2.0"
},
"devDependencies": {
"nodemon": "^2.0.9"
}
}
Today I updated my npm to 7.19.1, after that I am getting this error. Otherwise, it has to do something with nodemon.
Maybe the new version of nodemon is causing this. So, I've degraded the version to 2.0.7 which is working fine for me!
npm uninstall nodemon
npm install nodemon#2.0.7 --save-dev
You check nodemon -v, if nodemon is not recognized then npm install -g nodemon -> nodemon app.js
[enter image description here][1]
[1]: https://i.stack.imgur.com/UbQLM.png
try installing nodemon verson 2.0.7 globally
first install the current version npm uninstall -g nodemon
then write the command npm i -g nodemon#2.0.7
atleast it worked for me :)
Updating your nodemon to the latest version will resolve this issue.
npm install nodemon
Running above command will update nodemon to the latest version.
The system32 folder's path was not found. As soon as I added it to the system path, it worked as it should.The problem was not with nodemon, it was my system that was missing the system32 folder's path in environment variables. System32 folder contains important operating system files that Windows needs in order to function properly. For this case the command was not automatically refreshing (nodemon).
If Not solving you can uninstall nodemone and install it again this worked for me.
Related
When I am running nodemon run start it is giving me the following error
I am running this on macos. Not sure if that matters or not.
ERROR
node:internal/modules/cjs/loader:926
throw err;
^
Error: Cannot find module '/Users/jarvis/Documents/Backend/mongoTelusko/run'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:923:15)
at Function.Module._load (node:internal/modules/cjs/loader:768:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
[nodemon] app crashed - waiting for file changes before starting...
This is my app.js file
const express = require('express')
const mongoose = require('mongoose')
const url = 'mongodb://localhost/AlienDBex'
enter code here
const app = express()
mongoose.connect(url, {useNewUrlParser: true})
const con = mongoose.connection
con.on('open', function(){
console.log('Connected...')
})
This is my package.json file
{
"name": "mongotelusko",
"version": "1.0.0",
"main": "app.js",
"scripts": {
"start": "nodemon app.js"
},
"author": "malay",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"mongodb": "^3.6.5",
"mongoose": "^5.12.2"
},
"devDependencies": {
"nodemon": "^2.0.7"
},
"description": ""
}
"scripts": {
"start": "nodemon app.js"
},
Since you have specified "start" script in package.json, npm start command automatically calls nodemon app.js
However, you can also run the nodemon app.js manually which also has the same effect.
Wrong: nodemon run start
Correct: nodemon app.js or npm start
You're running nodemon run start, which tells nodemon to execute run (run.js) with argument start. Did you mean to use npm run start? Hint: You can also use npm start as a shortcut.
I've got the same error while I'm trying to run the code on my Mac.
I found why it is showing me this error:
first reason is that I've installed Node.js through an installation pack downloaded from [nodejs.org][1], but I should've installed node from the Terminal.
second reason is that I found out that I was trying to run the file from a different folder. I was in folder /users/practice/file-manager/frontend - trying to run the code from file which is located in directory /users/practice/file-manager/backend - the main reason which caused this error.
As a solution that worked for me:
make sure you've installed Node.js from terminal
make sure you're in the right directory when you're trying to run the .js file.
Maybe this information helps you.
My solution after trying new files, etc... didnt work. Then starting from the beginning:
deleting node.js and clearing cache about npm (from appdata)
creating new file and being sure about path you can confirm with 'cd'
trying to re-install npm_modules at my project folder.(npm install)
Then it worked.
I'm trying to get a simple electron application running that interacts with an HID device.
I am running into a lot of difficulty, I am able to install and run node-hid, just not within electron.
My package.json looks like this:
{
"name": "test-proj",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"start": "electron .",
"rebuild": "electron-rebuild --force",
"postinstall": "electron-rebuild"
},
"author": "me",
"license": "ISC",
"devDependencies": {
"electron": "^9.2.0",
"electron-rebuild": "^1.11.0"
},
"dependencies": {
"node-hid": "^1.3.0"
}
}
My main.js has the standard electron demo boilerplate code plus some HID calls:
const {app, BrowserWindow, ipcMain} = require('electron');
var HID = require('node-hid');
var device = new HID.HID(5824, 1500);
// Standard electron app window stuff
When trying to run the app I immediately get an error on new HID.HID():
Error: Module did not self-register: '\\?\C:\Users\Nathan\Desktop\carriage_return_app\node_modules\node-hid\build\Release\HID.node'.
at process.func [as dlopen] (electron/js2c/asar.js:140:31)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1034:18)
at Object.func [as .node] (electron/js2c/asar.js:140:31)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module._load (electron/js2c/asar.js:769:28)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at bindings (C:\Users\Nathan\Desktop\carriage_return_app\node_modules\bindings\bindings.js:112:48)
at loadBinding (C:\Users\Nathan\Desktop\carriage_return_app\node_modules\node-hid\nodehid.js:25:42)
Looking around I have seen a few examples of how to install node-hid and use it in electron, but none have helped me.
I have followed the electron-rebuild instructions here: https://www.electronjs.org/docs/tutorial/using-native-node-modules
I have also followed the instructions and copied the examples from here: https://github.com/node-hid/node-hid#electron-projects-using-node-hid
No luck. I get module did not self-register every time. node-hid is supposed to support electron and I don't see other people complaining.
Anyone come across this or have ideas to fix the issue?
The problem has been solved, so I will mark this as answered. I think I would still like more information on WHY though.
The hint came from building the two example projects:
https://github.com/todbot/electron-hid-toy
https://github.com/todbot/electron-hid-test
Running the first item, electron-hid-test worked off the bat. Adding electron-builder as a dependency and adding "postinstall": "electron-builder install-app-deps" as a script solved the issue in my project, I don't want electron-builder yet but at least it indicated that node-hid can work with electron given a specific setup.
The second item also worked, but not with:
npm install
npm rebuild
npm start
Instead it was specifically required to add the run command to the rebuild command:
npm install
npm run rebuild
npm start
After that, it works.
Any insights as to why this behaves differently?
Does someone know how to deploy meteor 1.4+ on IBM Bluemix?
Nothing seems to work.
meteor v 1.4.4.1
node.js v4.8.1
npm 4.2.0
mongodb 3.4.0
I tried demeteorizer github.com/XervoIO/demeteorizer but it doesn't figure out which version of nodejs it needs to set up.
I tried meteor buildpack github.com/ind1go/bluemix-buildpack-meteor, but it's 4+ years old, no way it'll work with meteor 1.4+.
I tried to run the application as a node.js one with the standard buildpack, I tried another from scalingo (github.com/Scalingo/nodejs-buildpack) which should support meteor better. This method is the one having the farest results even though I cannot succeed deploying. Here is the methode description:
npm install --production
meteor reset
meteor build /build --architecture os.linux.x86_64
cd /build && tar xvzf devance.tar.gz && chmod -R +w+x *
cd /build/bundle/programs/server/ && npm install
cd /build/bundle and create package.json with content:
{
"name": "myname",
"version": "1.0.0",
"dependencies": {
"meteor-promise": "0.8.0",
"fibers": "1.0.15",
"promise": "7.1.1",
"underscore": "1.5.2",
"source-map-support": "https://github.com/meteor/node-source-map-support/tarball/1912478769d76e5df4c365e147f25896aee6375e",
"semver": "4.1.0",
"node-gyp": "3.6.0",
"node-pre-gyp": "0.6.34"
},
"scripts": {
"start": "node main.js"
},
"engines": {
"node": "4.8.1",
"npm": "4.2.0"
},
"private": true
}
I test locally "node main.js", it works
cf push my-app -b https://github.com/Scalingo/nodejs-buildpack.git and it fails with the following error message from Bluemix CF.
ERR /home/vcap/app/programs/server/boot.js:356
ERR }).run();
ERR ^
ERR Error: Can't find npm module 'meteor-deque'. Did you forget to call 'Npm.depends' in package.js within the 'meteor' package?
ERR at Object.require (/home/vcap/app/programs/server/boot.js:200:17)
ERR at packages/meteor.js:677:32
ERR at packages/meteor.js:846:4
ERR at packages/meteor.js:1380:3
ERR at /home/vcap/app/programs/server/boot.js:303:34
ERR at Array.forEach (native)
ERR at Function._.each._.forEach (/home/vcap/app/node_modules/underscore/underscore.js:79:11)
ERR at /home/vcap/app/programs/server/boot.js:128:5
ERR at /home/vcap/app/programs/server/boot.js:352:5
ERR at Function.run (/home/vcap/app/programs/server/profile.js:510:12)
OUT Exit status 1
It clearly doesn't find the demetorized meteor packages. Any solutions would help.
Thanks
Scalingo's CTO and author of the buildpack here. A little disclaimer first. The buildpack has been designed to work on the Scalingo hosting platform first, but should work anywhere in theory. (In theory because it has not been tested properly elsewhere)
According to your error, the issue is related to a missing dependency in your package.json, you should run meteor npm install --save meteor-deque and commit the new version of the file. Then it should work as expected.
Regards,
Getting started with NPM...
I can run the following command to start my app.
node app
But when I run the following command, I get the following error:
npm start
Windows Script Host
Object expected
Line 2
800A138F
Microsoft JScript runtime error
App.js:
var port = 5000;
var express = require('express');
Package.json:
{
"name": "2",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "app.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.13.3"
}
}
And I've run this command of course:
npm install express --save
Seems like NPM can't find the express package? Why not?
I know its too late to answer, but in case any wanderer like me faces the same problem in future..
Solution:
need to add node keyword ahead of app.js in script. So, start script should
"scripts": {
"start": "node app.js"
},
That solved for me.
I had this problem as well. The .js files are associated with the Microsoft Script Engine. Some suggested that we dis-associate the extension with the program, but I do not think that is necessary. I was able to fix the issue with the following instruction that I found in the NODE Docs.
Please make sure that your file(s) referenced in bin starts with
#!/usr/bin/env node
otherwise the scripts are started without the node executable!
Use >node app.js instead of >app.js
Then it will work
When I faced the same problem using Visual Studio Code, I was trying to run localhost at port 8080, however by pressing F5 I was able to know that the port was already taken and so I changed the port to 3000, and viola! that worked for me.
Check out the error
If you're using Visual Studio Code, it may have taken over running the script. If in VS Code, hit F5 and see if the project runs properly.
I don't know why it does this, but did for me. This tipped me off
NightmareJS on c9.io is literally a nightmare.
i cannot get it to work at all i am going to run through the whole process from start to finish.
Step 1
I create a new workspace
Hosted
Node.js
Step 2
Start Editing my new workspace
I open Package.json and add what i need heres my file.
{
"name": "chat-example",
"version": "0.0.0",
"description": "A chat example to showcase how to use `socket.io` with a static `express` server",
"main": "server.js",
"repository": "",
"author": "Mostafa Eweda <mostafa#c9.io>",
"dependencies": {
"async": "~0.2.8",
"express": "~3.2.4",
"socket.io": "~0.9.14",
"phantomjs": "*",
"casperjs": "*",
"nightmarejs": "*",
"utils": "*",
"crypto": "*"
}
}
i then run 'npm install' in the console.
Step 3
this is where it does not work i try all theses diffrent commands to get the examples running and the errors i get.
#stackoverflow:~/828481 $ cd node_modules/nightmarejs/examples/
#stackoverflow:~/828481/node_modules/nightmarejs/examples $ node server.js casper.js
Error: Cannot find module 'crypto'
phantomjs://bootstrap.js:289
phantomjs://bootstrap.js:254 in require
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/utils/utils.js:7
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/utils/utils.js:117
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/utils/utils.js:118
Error: Cannot find module 'casper'
phantomjs://bootstrap.js:289
phantomjs://bootstrap.js:254 in require
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/nightmarejs/lib/nightmareClient.js:4
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/nightmarejs/lib/nightmareClient.js:83
TypeError: 'undefined' is not a function (evaluating 'require(phantom.args[3].slice(13)+'nightmareClient.js').Nightmare({
exitOnError: false
})')
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/nightmarejs/lib/nightmareTest.js:16
I have it working. I also had trouble at first. I tried downloading the prebuilt package, but I can't seem to get that working. I ended up just adding the following to my package.json file and ran npm update and all was well:
"nightmare": "^1.5.0",
"phantomjs": "~1.9.7"
Probably they've updated the npm repo and everything since you've posted this. I bet it was frustrating. I don't have those examples in my install, but I would guess you could run them if you had all of the right pre-req's installed.