How to run node.js applications locally for development - javascript

I am new to node.js,today I joined in another team they are working with node.js,backbone.js,marionette.js and sqlserver.I have an idea about backbone,Marionette but I never work on node.js.They asked me to clone the git repository,As per their suggestion I installed node.js.
After cloning the repository,I got the files just in the following way.
I opened node_modules folder,It has nearly 10 sub-folders are there.
node-sqlserver doesn't have any files inside.might be because of that I am getting the following error while server running time.
I ran the server with the following command
node server.js local
getting the following error
I don't know,why I am getting.can anyone help me.
Thanks.

You need to install all the dependent modules through npm install, In your case, you need to install node-sqlserver.
npm install node-sqlserver
Generally your source code will be having a package.json. This file specifies all the
dependent modules required to run the application, but here this file is missing.

Related

Could not list contents of 'third-party/glog-0.3.4/test-driver'. Couldn't follow symbolic link

I have a project build on react-native version 0.55.4. It was woking fine on old system. I have to change system due to some reasons. I setup on new system, I am able to run project using react-native run-android but when building a signed APK using ./gradlew assembleRelease I am receiving following error.
Task :app:processReleaseGoogleServices
Parsing json file:
<Project-Directory>/android/app/google-services.json
FAILURE: Build failed with an exception.
What went wrong:
Could not list contents of
'<Project-Directory>/node_modules/react-native/scripts/third-party/glog-0.3.4/test-driver'. Couldn't follow symbolic link.
I know this issue is already on stack overflow Invalid symlink in node_modules error when trying to deploy to simulator (RN 0.45). I have tried it. I have also tried following github question.
https://github.com/facebook/react-native/issues/11212
https://github.com/facebook/react-native/issues/14417
https://github.com/facebook/react-native/issues/14548
https://github.com/facebook/react-native/issues/14464
I have also tried following things.
Deleting node modules and reinstalling them
Deleting .bin folder in node modules
Deleting react-native/third_party folder in node modules.
Copying node modules from older system.
Copying third-party and glog-0.3.4 from older system.
Deleting test-driver file inside third-party folder.
Unlinking test-driver file inside third-party folder.
Installing automake-1.16 and creating a new alias of test-driver file inside third-party folder.
My java version is 1.8.0_201. My android studio version is 3.3.2. Projects react native version is 0.55.4. My mac os version is 10.14.4. My x code version is 10.2.
Please help.
Thanks in advance.
Unlinking as below and restart with the cache cleaned
In project folder:
unlink ./node_modules/react-native/scripts/third-party/glog-0.3.4/test-driver
and then stop js server and run:
npm start -- --reset-cache
It should work

How can I test local installation of an NPM package I've published?

I recently published a package to NPM. The package works well on my own computer, where I wrote the code, but upon npm install on a coworkers machine, I start receiving errors.
What is the best way to go about installing and testing my package on my own computer? I could trace through the errors on my coworkers computer, but I assume there is a way I can do this on my own machine.
You don't have to install it on your own computer first if you want to test it, you could write unit tests instead, since you have to require the package if you do (just like an npm install).
Check the package.json to see if all needed modules are listed under dependencies. (Delete the node_modules folder, run npm install and see what errors are given)
If there is a file called .npmrc, check what files/folders it lists to make sure it's not excluding important files from NPM.
Make sure your module has a module.exports object, to be able to access the objects/functions
If this all didn't help, it might be a more specific problem and a GitHub link would help us more

Node.js - Cant run project

im trying to run a node.js example project that i downloaded from here
I downloaded node.js and npm and checked both versions using CMD as seen below.
At first the version of npm wasnt compatible but i followed a youtube guide and now it seems the versions are compatible. If i didnt mention, im using Windows os.
I then installed the socket package by typing in "npm install socket.io#0.9.10 node-static" in cmd and a bunch of writing happened until it finished.
I then open cmd and do, "cd ... then the folders which contain the project" until its the root folder.
I then type in cmd "node app.js" which is the js file contained in the project.
I get this as a result:
The tutorial im following then tells me to go to http://localhost:8080 to see a local copy of the demo but when i do, chrome just loads and loads then after a few minutes says it cant be reached. does anyone know what im doing wrong? any help is appriciated
afaict you're not doing anything wrong, Doesn't work for me either. It was written in 2012 so it's quite possible this worked fine with an older version of Node.JS and older versions of some dependencies. To get it working for me locally I made the following changes:
Change the handler function in app.js to
function handler (request, response) {
fileServer.serve(request, response);
}
And instead of installing an old version of socket.io I installed the latest. You may want to delete your node_modules directory in the project and then:
npm install socket.io node-static

Uncaught Error: Module did not self-register

I try to use node-vlc with nw.js (v0.12.0-alpha2). When i launch my app without nw.js it works, but when i launch it with nw.js i got an error:
Uncaught Error: Module did not self-register.", source: /home/alexis/Bureau/dev/jukebox/node_modules/vlc/node_modules/ffi/node_modules/bindings/bindings.js (84)
I tried some commands with nw-gyp but it couldn't help me.
I am on Ubuntu 14, 64-bit.
If you've upgraded node then npm rebuild might fix this for you
For me:
rm -r node_modules then
npm install
I had a similar issue with another product and my fix was to change the version of node I was using. I was using 0.12.0 and changed back to 0.10.26.
Personally, I use NVM to handle node version changing. With NVM installed it's as simple as running
nvm use 0.10.26
Or setting the default version to 0.10.26
nvm alias default 0.10.26
Hopefully this helps you out - our issues came from different products but the solution may be the same.
I had similar problem.
/Users/user/NodeAddons/bridge/node_modules/bindings/bindings.js:83
Error: Module did not self-register.
In my case I was doing a C/C++ Add-on, and I had forgotten to export the add-on, in my main.cc was missing the code below:
void Init(v8::Handle<v8::Object> exports) {
NODE_SET_METHOD(exports, "method", method);
}
NODE_MODULE(method, Init);
Hope this helps others!
Thanks :)
I've add the same issue because I installed to modules as sudo...
Removing the node modules folder and reinstalling as normal user fixed it.
For me npm rebuild or npm update didn't work. I had to remove the node_modules folder and run npm install to install them again.
I once had this problem when creating a multi-file c++ addon. In my binding.gyp file I had:
"sources": ["src/*.cc", "src/*.h" ]
And my project contained several *.cc files. However, the NODE_MODULE() macro was called only on one file which imported the rest of the files. But node expects that it is called on the frist *.cc file listed in sources. So I had to change sources to explicitly add that file to the beginning
For me, running npm update worked
I was getting an internal error: Module did not self-register.
Deleted the node_modules folder
ran npm install
It worked just fine.
I had this error with Snappy. Was using Node 11. Checked Snappy's NPM page https://www.npmjs.com/package/snappy where they listed which versions of node they supported.
Deleting node_modules folder rm -rf node_modules and then reinstalling using the correct version of Node resolved it.
One of the versions they supported on Linux at the time of this writing was Node version 12.
nvm deactivate 11
nvm uninstall 11
nvm install 12
nvm use 12
Problem solved
Another cause of this problem: if you're using pm2, then after upgrading node you may need to reinstall pm2. Test whether pm2 is the issue by running your app
without pm2 node server.js
then with pm2: pm2 start server.js.
Proper way to update PM2 after updating Node.js
I had this same issue with 0.12 and io.js 1.3.0, reverting to Node.js 0.10 fixed the issue.
Rebuild your C++ add-ons.
Did you encounter something like this?
Module did not self-register: '…\node_modules\#u4\opencv4nodejs\build\Release\opencv4nodejs.node
It’s likely that you have just updated your Node.js. Once you updated your Node.js, you need to rebuild your C++ add-ons, Node.js packages written in C++.
Why
When you build Node.js’ C++ add-ons, they get compiled into require-able .node files and linked to the currently installed Node.js ABI library, which is not compatible with other versions of it. Your packages were built only compatible with the specific version of Node.js.
How
Firstly, try npm rebuild. If your C++-add-on-based packages have a build script, it’ll do. If it doesn’t, you need to manually build your C++ native add-on packages. Do again what you did when you were installing such packages. Refer to the building instructions in the packages’ documentations to rebuild them. Or try reinstalling (npm install) them.
I had the same problem. My script that was referencing a global reference script had an invalid reference. I took off that invalid reference and the error was gone. My error message had no indication of that particular invalid reference which made it harder to debug. But 'Uncaught Error: Module did not self-register' was the message I was getting.
This also happen in my other project. For some reason, it wouldn't recognize the reference path if one of the characters are uppercase. Even thought, the upper-casing was the correct spelling of the path.
I had this issue while setting up my Cypress project.
I found out the issue was caused because Cypress uses node from its bundle version by default (which was version 8.0 in my case) , whilst the package I wanted to use required the node version to be 10 or higher.
I did have node 12.0 installed on my machine but since cypress was not using that I had to add the line shown below in the settings file (cypress.json) to set the value for 'nodeVersion' to 'system', to tell cypress explicitly to use the node version installed on my machine.
Add this line to your settings file:
**"nodeVersion": "system"**

error installing/running Meteor with MySQL

I have installed Meteorite on my mac, and am trying to run the test program provided as a mysql project. When I use the command 'mrt', I get:
Stand back while Meteorite does its thing
Done installing smart packages
Ok, everything's ready. Here comes Meteor!
[[[[[ /Users/lfrey/Desktop/Thesis/test-meteor-sql ]]]]]
=> Errors prevented startup:
While building the application:
node_modules/meteor/app/lib/unsupported.html:1: Can't set DOCTYPE here. (Meteor sets for you)
node_modules/meteor/app/meteor/meteor.js:1:15: Unexpected token ILLEGAL
=> Your application has errors. Waiting for file change.
I have tried re-installing nom, meteor, meteorite, and mysql in various combinations and have not been able to eliminate the error. If I remove the command, then I get an error about invalid HTML syntax.
Your app might not be created properly. You have a node_modules directory in your application which you might have added with npm install.
Meteor does not install modules with npm install manually, it doesn't work because it parses files in the node_moules directory as part of your meteor app (in the wrong way - not as an npm module).
You have to make sure the package you use uses Npm.depends in your package's package.js. The standard Meteor-SQL package already does this for you so you don't have to worry about it.
Which SQL package did you use? As far as I can see none of them install anything with npm install nor do they have instructions to.
The simple fix to get your app working is to remove the modules you installed by deleting the node_modules directory in your app.

Categories