NodeJS Debugging Error: No such module: http_parser - node.js

I was debugging my nodejs app in vs-code without errors, but suddenly it did begin to give this error:
Error: No such module: http_parser
at internalBinding (internal/bootstrap/loaders.js:104:17)
at _http_client.js:27:24
at NativeModule.compile (internal/bootstrap/loaders.js:363:7)
at NativeModule.require (internal/bootstrap/loaders.js:174:18)
at http.js:25:27
at NativeModule.compile (internal/bootstrap/loaders.js:363:7)
at Function.NativeModule.require (internal/bootstrap/loaders.js:174:18)
at Function.Module._load (internal/modules/cjs/loader.js:517:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
Actually the app works successfully, for example, express-js http functions work as expected, but i am unable to do debugging.
I have already installed that package, named as http-parser
Edit: Node Version: v10.14.2, there is no extensions installed, just the vs-code built-in debugging runtime. After i have inspected more, the execution was coming to the loader.js and was terminating afterwards.
Edit2: Renaming the project folder fixed the issue but why? Could anybody explain this?

What version of node.js and vs code are you debugging?
Some Solutions:
1.Try to rename the project folder
2.Disable extensions and see which extension is influencing the debugging
3.You could also disable the check boxes
All Exceptions and Uncaught Exceptions under Debug > Breakpoints, can debug your application
check if it works

Go to the debugger tab, go the Breakpoints section, and disable "All Exceptions" and "Uncaught Exceptions"

Deleting .vscode folder in working directory will help but if your debugging points are not getting enabled then try updating vscode. This happened with me when I was using latest nodejs version but a moderately old version of vscode.

Related

package node with pkg ERR_INSPECTOR_NOT_AVAILABLE at run time

I am playing with pkg to package a command line example I got from a blog post. The executable created fine but when I try to run the executable, I am getting the following error:
pkg/prelude/bootstrap.js:1244
throw error;
^
Error [ERR_INSPECTOR_NOT_AVAILABLE]: Inspector is not available
at inspector.js:24:9
at NativeModule.compileForInternalLoader (internal/bootstrap/loaders.js:276:7)
at NativeModule.compileForPublicLoader (internal/bootstrap/loaders.js:218:10)
at loadNativeModule (internal/modules/cjs/helpers.js:25:9)
at Function.Module._load (internal/modules/cjs/loader.js:906:15)
at Module.require (internal/modules/cjs/loader.js:1087:19)
at Module.require (pkg/prelude/bootstrap.js:1225:31)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous> (/snapshot/ginit/lib/repo.js:11:17)
at Module._compile (pkg/prelude/bootstrap.js:1320:22) {
code: 'ERR_INSPECTOR_NOT_AVAILABLE'
}
I put the package on github and here is the link: Link to github
Any help is greatly apprecited on how to get this to work.
This Error comes up when we try to Start the executable in DEBUG mode.
Since pkg doesn't allow Inspecting the run-time code of the executable this error Inspector is not available shows up.
I was trying to spawn the executable from another program (which was running in DEBUG mode) and it caused the same issue.
But when I started the program in normal mode, it worked like a charm

Error: Cannot find module '/Applications/Atom.app/***/electron.asar/browser/init.js' while attaching debugger to nodejs

I'm trying to debug my node script using atom-node-debugger plugin.
Below are the commands I used to start the node script -
When I try to attach the debugger I am getting below error -
throw err;
Error: Cannot find module '/Applications/Atom.app/Contents/Frameworks/Atom Helper.app/Contents/Resources/electron.asar/browser/init.js'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:473:25)
at Function.Module.runMain (module.js:683:10)
at startup (bootstrap_node.js:196:16)
at bootstrap_node.js:622:3
Process exited (Port: 9229 (Node attach))
How can I resolve this error?
Am I missing something?
As mentioned in the error, that file does not exist. In the most recent version of Atom (1.38.x at the time of this writing), the file electron.asar is located at Atom.app/Contents/Resources, but not inside the Atom Helper.app.
There are several issues open on GitHub with a similar error. Looks like the package is outdated and no longer actively maintained.

Error: The specified module could not be found

I'm trying to use edge.js to execute some .NET code to print on windows in an Electron app. I've tried electron-edge and I've also tried manually building the edge.js modules targeting Electron following the instructions in the Electron docs, but I keep getting the following error when I try to use edge in the packaged app:
Error: The specified module could not be found.
\\?\C:\path\to\app\app-1.0.0\resources\app.asar.unpacked\node_modules\edge\lib\native\win32\x64\6.5.0\edge_nativeclr.node
at Error (native)
at process.module.(anonymous function) (ELECTRON_ASAR.js:178:20)
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:178:20)
at Object.Module._extensions..node (module.js:583:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:192:18)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
I've checked the filesystem and the edge_nativeclr.node module does, in fact, exist. My suspicion is that I'm somehow not building the module correctly and it's perhaps targeting the wrong version of node still and so electron is unable to import the module.
I tried several different things, including following electron-edge's steps to manually update the build.bat and add the --target=1.4.12 --dist-url=https://atom.io/download/atom-shell flags to the node-gyp configure build.
I also set the following npm config options in my .npmrc:
target=1.4.12
arch=x64
target_arch=x64
disturl=https://atom.io/download/electron
runtime=electron
build_from_source=true
msvs_version=2015
And ran the build.bat, making sure to set the EDGE_NATIVE environment variable to point to the generated edge_nativeclr.node file, but got the same result.
I finally got this figured out after banging my head against the keyboard for a couple days. I got some hints from electron-userland/electron-packager#217 and electron/electron#892, which pointed out that this error, "The specified module could not be found," could occur when the native module is missing a dependency, such as a .dll, and that you could use Dependency Walker to check the dependencies of any given .node module.
I loaded edge_nativeclr.node in Dependency Walker and noticed that VCRUNTIME140.DLL, the Visual Studio 2015 C runtime, was missing. Edge.js comes with the msvcr120.dll, the Visual Studio 2013 C runtime, but I'd been rebuilding the module with the msvs_version set to 2015.
Once I placed a copy of the vcruntime140.dll in the same directory as edge_nativeclr.node, everything started working as expected.
I also got this error even though I did have VC++ Redistributable x64 installed correctly. It turns out the error in my case was not actually a problem since everything worked fine (I was able to run the electron-quick-start app with electron-edge).
Even so, the author has fixed the install so that the error does not occur. https://github.com/kexplo/electron-edge/issues/25#issuecomment-272908409
Aside note, if you load edge_nativeclr.node in Dependency Walker, you will see the VCRUNTIME140.DLL resolved properly (e.g. under C:\Windows\System32 on my PC). However, you may see several question marks and errors. It turns out these are just due to some limitations in Dependency Walker and not an actual issue. See Dependency Walker: missing dlls

Task Runner Explorer window had "failed to load" under my Gulpfile.js and none of the build processes were listed

This happened randomly as I was updating my CSS file and then refreshing to notice no changes were being shown. I eventually noticed that Task Runner Explorer window had "failed to load" under my Gulpfile.js and none of the build processes were listed.
I then done a bit of research and reordered the list of external tools as some SO threads have mentioned to do and nothing. I then noticed that gulpfile.js required some files :
var gulp = require("gulp"),
gulpless = require("gulp-less"),
sourcemaps = require("gulp-sourcemaps"),
rimraf = require("rimraf");
None of these were in the node_modules folder so I done npm install gulp-less and npm install gulp-sourcemaps and now checked in Output>Task Runner Explorer and have the following error.
Failed to run "C:\projects\Fusion\FusionMVC\Gulpfile.js"...
cmd.exe /c gulp --tasks-simple
C:\projects\Fusion\node_modules\gulp-sourcemaps\node_modules\strip-.bom\index.js:2
module.exports = x => {
^
SyntaxError: Unexpected token >
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (C:\projects\Fusion\node_modules\gulp-sourcemaps\src\init.js:10:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
Any clues or solutions as to what might be wrong and how to get it working would be great! Gone through most of the SO threads and that solution did not work.
So after tonnes of research, working through SO threads and npm tutorials I finally found the issue. It looks like the PATH variable (not sure if it used the system or user level one) might have been incorrect. I have never touched them but after adding a direct path to the locally installed packages folder and putting it at the top of the external tools locations list it worked.
A few things to look for though before even worrying about the path would be:
ensure that all the correct npm packages are installed
gulpfile.js code is correct
node.js and npm are both up to date
The problem is not related to path, but actually there must be some problem with gulp file itself either syntax error or some package is missing which unfortunately visual studio does not show that specific error but generic error what you see in task runner "failed to load". And the right way to see the errors is
Open the command prompt (preferably in admin mode, this is what i did).
Go to the same location where gulp file is located.
Run the task through following command example --> gulp default
If there is any error like package is missing, it will show you, fix those issues.
After all errors are fixed, then you will see that gulp task runs successfully.
Go back to visual studio, task runner, and click on refersh (left top button), and it will show you all tasks.
#SharpCode's solution worked great, though if you are using VS2019 it has moved to Options > Projects and Solutions > Web Package Management > External Web Tools:
I had same issue for my .net core solution.
Steps I did which fixed my error and started to Gulping my mins/js/styles:
Uninstall existing Node.js from [add or remove programs]
Install a new Node.js from https://nodejs.org/en/ [64bit recommended one]
open cmd and check if npm is working
Open my Solution in visual stuido -> Open node.js interactive window from view ->
other windows
in the node.js interactive window enter the below command
.npm [ProjectName] install gulp
P.S. dont get confuse here we dont need to write projectname.csproj or d:/repo/projectname.csproj just write projectname as its already inside the solution.
Thats all, it solved my problem
Funny running on VS 2022, I recently experienced the issue, I googled and I have tried everything mentioned in this post and any other posts I could find on the net, but none worked, I knew my gulpfile was fine since it was working on another pc, Then I read there is a bug apparently in VS since 2019 that can cause this and here is a workaround
Go to
Tools > Options > Projects and Solutions > Web Package Management >
External Web Tools
you will see something like the following window,
Now just move item $(PATH) to the top using the arrow at the top right corner and click ok, close visual studio, load the project again, locate the
'gulpfile.js' file, right click Task Runner Explorer just like you see as follow and you should be good

Almost finishing app and it started crashing

My app was working perfectly until I installed the accounts-facebook and service-configuration package. Now it's giving this error and I have absolutely no idea how to fix it:
/Users/###/.meteor/packages/meteor-tool/.1.1.3.1eul34x++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
throw(ex);
^
Error: Can't find npm module 'mongodb'. Did you forget to call 'Npm.depends' in package.js within the 'cfs_gridfs' package?
at Object.Npm.require (/Users/###/proyectos/leads/.meteor/local/build/programs/server/boot.js:155:17)
at Package (packages/cfs:gridfs/gridfs.server.js:2:1)
at /Users/###/proyectos/leads/.meteor/local/build/programs/server/packages/cfs_gridfs.js:189:4
at /Users/###/proyectos/leads/.meteor/local/build/programs/server/packages/cfs_gridfs.js:196:3
at /Users/###/proyectos/leads/.meteor/local/build/programs/server/boot.js:222:10
at Array.forEach (native)
at Function._.each._.forEach (/Users/###/.meteor/packages/meteor-tool/.1.1.3.1eul34x++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
at /Users/###/proyectos/leads/.meteor/local/build/programs/server/boot.js:117:5
Exited with code: 8
Your application is crashing. Waiting for file change.
What worked for me was simply hitting "Control + C" to stop my app and then running "meteor run" again.
Do you have the cfs_gridfs package?
Your console reference that package in the error
If you're using mrt it means that you're using an old version of Meteor. Once in a while I had similar issues and I would simply edit the file .meteor/packages and the problem was solved when I run meteor command. I'm not sure if the same applies here.

Resources