node.js:201 process.nextTick error? - node.js

So I'm messing around with meteor, and out of no where I received this error? What is it asking me to change?
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
SyntaxError: Unexpected end of input
at /Users/devinandrews/my_cool_app/.meteor/local/build/server/server.js:109:21
at Array.forEach (native)
at Function.<anonymous>(/Users/devinandrews/my_cool_app/.meteor/local/build/server/underscore.js:76:11)
at /Users/devinandrews/my_cool_app/.meteor/local/build/server/server.js:95:7
Exited with code: 1
Your application is crashing. Waiting for file change.
Thanks guys..

You need to look through the code and see what it's doing in server.js around 109. It is probably working with a network connection that is being abruptly terminated. Are you doing anything like accessing your site with curl and CTRL-C-ing it while it's connected to your server? Because of the disconnected nature of vanilla node.js stack traces, we need to see the code to help you debug this.

This error comes up when you have a syntax error. Perhaps you are missing a closing brace in server.js?

Check that you don't have duplicate and possibly conflicting versions of modules in your global and local paths.
npm list
and
npm list -g
should not list duplicate and/or conflicting versions of modules.
In my case I had ws installed locally and some of its dependencies were also on the global path.
My solution was to remove everything from my local path and just install everything globally.

I've came across this error when I tried to start my server running on ubuntu on a well-known port (0-1023)
If that's the case, just run it as superuser (sudo)
In case that's not possible for you, check out this alternative (https://serverfault.com/a/112798)

in my experience was getting that error, caused by NPM and Node are not match version.
Need make sure NPM and Node are match (not mean same version)

Related

angular project npm modules randomly deleted

I have the weirdest problem I've ever seen with npm where in the middle of running an angular ng serve, packages from both node and for angular will randomly go missing. In the middle of a save, the project will suddenly not recompile, and will complain about a missing module. Each time it has been different but so far I have had:
Error: ENOENT: no such file or directory, open '.../node_modules/core-js/internals/hidden-keys.js'
Module not found: Error: Can't resolve '../internals/is-pure' in '/.../node_modules/#angular-devkit/build-angular/node_modules/core-js/internals'
An unhandled exception occurred: Cannot find module './internal/streams/stream
An unhandled exception occurred: Cannot find module '/.../node_modules/minipass-collect/node_modules/minipass/index.js'.
Please verify that the package.json has a valid "main" entry
These have just been errors from the last few days, but issues like this has been happening all. to the point where I need to delete node_modules and reinstall everything via npm at least once a day. I'm thinking the error has more to do with node or NPM than with my Angular set up, as some of these missing packages appear to be node core packages.
I've already tried reinstalling npm globally via npm install -g npm and it hasn't helped anything. I'm afraid that I'm going to have to just reinstall node completely.
Any help would be appreciated, thank you.
EDIT: upon further debugging, I'm noticing that the modules missing are always from #angular-devkit/build-angular/node_modules/core-js/modules. In addition to losing random modules like 'is-pure', the app will also randomly recompile many times when running ng serve
I figured out what was going on, if anyone in the future has the same problem. Turns out the answer has nothing to do with me botching my npm config. I didn't realize that on new Macbooks, any directory in the desktop is automatically managed by iCloud. At some point, probably an older version of the code before I migrated to Angular 9 was syncing the old code into my project. I was able to resolve this issue by changing the name of the parent directory where my project lived from filename to filename.nosync. adding '.nosync' causes iCloud to ignore syncing for whatever is in that file. I know I should have caught this, but hopefully this will help any mac users in the future who are experiencing similar problems.

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.

Error when starting Nodemon on my server.js file (Nodejs)

I recently started getting an error in my terminal when I start nodemon on my server.js file within my directory. Here is a picture below
Here is the error.
dyld: lazy symbol binding failed: Symbol not found: _node_module_register
Referenced from: /Users/dan/nodeStuff/crm-test/node_modules/mongoose/node_modules/mongodb/node_modules/bson/build/Release/bson.node
Expected in: dynamic lookup
Not sure what the issue is. I did a brew update and also made sure my port was correct.
For anyone else who stumbles by this problem, I had the same issue when trying to start my server with nodemon.
For me, the problem was I was still using an older version of node with nvm. I switched back to the version appropriate for my application and problem solved!
Did you try running node server.js?
Maybe it's not nodemon.
I've looked around and I did a npm rebuild which helped. When I start nodemon server.js or node server.js it tells me that one of the packages I was using is depreciated, I'm guessing that's what threw the error. Not sure why body-parser is depreciated.

Seriously debugging node.js 'Cannot find module xyz/abcd'

I have the Error: Cannot find module xyz/abcd error.
YES, the required module is installed.
According to the pseudo-code of module.require here, it should work.
I tried to dive inside require() to understand why it can't find my file. My node debugger won't step into require(). I've tried the strace / grep NOENT technique whithout success either.
Any idea how to troubleshoot a nasty require() failure ?
Note : just in case : the error comes from a file node_modules/xyz/a requiring xyz/b. It should work according to the doc.
By investigating more, I think I found a good technique :
export NODE_DEBUG=module
node my_script.js
gives such interesting traces :
looking for "/(...)/tests_init.js" in ["/home/(me)/.nave/installed/0.10.24/lib/node","/home/(me)/.node_modules","/home/(me)/.node_libraries","/home/(me)/.nave/installed/0.10.24/lib/node"]
And BTW, it shows that node is not searching at all where I thought it was. Time to investigate...
[edit] end of the story :
1) it appears that node is not treating well modules installed with npm link. require(...) sometimes fails to select files from inside a npm-linked module. I have no desire to investigate further the exact error conditions, I'll just conclude that npm link is very brittle.
2) beware of node looking for node_modules all the way into the parent dirs of current working directory ! I found that modules from parent folders of my app where sometime selected !

Error running sample code using Spooky.js

I am new to the whole stack of node.js, phantom.js, casper.js and spooky.js. I have everything installed (in Windows), with PATH updated and followed this example:
https://github.com/WaterfallEngineering/SpookyJS
I got this error:
C:\node_modules\spooky>node examples/hello.js
events.js:68
throw arguments[1]; // Unhandled 'error' event
^
Error: Child terminated with non-zero exit code 127
at Spooky._spawnChild.Spooky._instances.(anonymous function) (C:\node_module
s\spooky\lib\spooky.js:82:17)
at ChildProcess.EventEmitter.emit (events.js:96:17)
at Process._handle.onexit (child_process.js:678:10)
Anyone has any clue why and how to fix it? I run casperjs googlelinks.js just fine. But with node.js and spooky.js, it gave me trouble.
This is due to the CasperJS Windows executable being named casperjs.bat instead of casperjs. See this comment on the bug #mike mentioned.
Unfortunately, you'll have to hack around this bug for the moment. I will release a fix for that this week.
This is based on the workaround provided by #mike and #lawnsea, which did lead me to the solution, but were not immediately clear to a beginner like me. The tip from minaki also helped me understand what to do: https://github.com/WaterfallEngineering/SpookyJS/issues/14
INSTALL SPOOKY.JS ON WINDOWS 7 WITH NPM.
I'm using:
Win7 64 bit
Node v0.10.17
CasperJS 1.1.0-DEV
PhantomJS 1.9.2
Added everything to my $PATH already
Steps:
Fresh directory: mkdir spookytest, cd spookytest
npm install spooky
open spookytest\node_modules\spooky\lib\spooky.js in a text editor
Change Line 26 (defaults.child.command) from 'casperjs' to 'casperjs.bat'
Change Line 30 (defaults.child.transport) from 'stdio' to 'http'
Save and go back to the spookytestdirectory
node node_modules/spooky/examples/hello.js
--> Hello, from Spooky the Tuff Little Ghost - Wikipedia, the free encyclopedia

Resources