I'm using NodeJs v0.10.29 and Express, among other things, for a project I'm working on.
The thing is that since I updated NodeJs to version 0.10.29 (from 0.10.28) a very annoyning thing is happening when I start the Express server up.
A very common issue was to look in the log generated by Express to see what was happening in case of error but now it's not possible without killing the server. Terminal scroll is locked (it can't go up...) because some kind of "helix" is spining round during "idle time" (| / - | \ | ....) at the end of the log.
Is it possible to avoid this without going back to 0.10.28?
Thanks
León
It is not node doing this. It's probably one of the modules you are loading from npm, but probably not express either. You need to investigate with process of elimination to find what piece of code is doing that. Most likely the last time you ran "npm install", you got a newer version of some module and the new version does this but the old didn't.
I've found out who's the one: npm is guilty of this thing.
I used to type
$ npm start
which is defined as
"scripts": {
"start": "nodemon app.js"
}
If I use
$ nodemon app.js
log behaves as it used to.
npm added this "helix" at the end of the log. It can be seen when you use, for example:
$ npm install my-favourite-package
Version of npm is 1.4.14
Related
There is probably an obvious answer to someone who is more familiar with NodeJS than me but:
When running an application which is using a node-gyp package, it runs without problems using
node ./src/index.js
However running it using a very simple package.json start-script:
"scripts": {
"start": "node ./src/index.js"
}
in npm:
npm start
npm info it worked if it ends with ok
npm info using npm#6.9.0
npm info using node#v11.10.1
npm info lifecycle rosbag2#0.1.0~prestart: rosbag2#0.1.0
npm info lifecycle rosbag2#0.1.0~start: rosbag2#0.1.0
> rosbag2#0.1.0 start /Users/andreasklintberg/personal/xviz/examples/converters/rosbag2
> node ./src/index.js "./src/index.js"
internal/modules/cjs/loader.js:779
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: dlopen(/Users/andreasklintberg/personal/xviz/examples/converters/rosbag2/node_modules/rosbags2_nodejs/build/Release/rosbags2_nodejs.node, 1): Library not loaded: #rpath/librosidl_typesupport_cpp.dylib
Referenced from: /Users/andreasklintberg/personal/xviz/examples/converters/rosbag2/node_modules/rosbags2_nodejs/build/Release/rosbags2_nodejs.node
Reason: image not found
And similarly in yarn
yarn start
yarn run v1.13.0
warning package.json: No license field
$ node ./src/index.js ./src/index.js -d ../../../data/rosbag2/rosbag2_2019_03_09-21_54_44 -o ../../xviz-data/rosbag2/rosbag2_2019_03_09-21_54_44/
internal/modules/cjs/loader.js:779
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: dlopen(/Users/andreasklintberg/personal/xviz/examples/converters/rosbag2/node_modules/rosbags2_nodejs/build/Release/rosbags2_nodejs.node, 1): Library not loaded: #rpath/librosidl_typesupport_cpp.dylib
Referenced from: /Users/andreasklintberg/personal/xviz/examples/converters/rosbag2/node_modules/rosbags2_nodejs/build/Release/rosbags2_nodejs.node
Reason: image not found
I know the error is because a dynamic link/#rpath is messed up, and I was thinking it was because npm/yarn messes with the env variables or something, but running yarn env it seems everything is correct.
So I guess i'm wondering if anyone know what the difference is running it in native node and using npm/yarnscript to wrap the start? And why this difference messes up the #rpath/dynamic linking ?
Edit:
My index.js file is very simple, just imports the built node-gyp package:
let RosbagDeserializer = require('../build/Release/rosbags2_nodejs.node');
const deserializer = new RosbagDeserializer.Rosbag2Wrapper();
This is the project in question, https://github.com/klintan/rosbag2_nodejs
I would love a more comprehensive answer but at least I solved it with the help of a lot of wonderful commenters:
The #rpath is not set on Mac, but with DYLD_LIBRARY_PATH it works, because that is one of the runtime search paths, it seems (https://superuser.com/questions/282450/where-do-i-set-dyld-library-path-on-mac-os-x-and-is-it-a-good-idea). However for some reason NPM removes this, I'm guessing it has to do with SIP on Mac, or maybe some other security measure that removes this env variable.
DYLD_LIBRARY_PATH is available if you run node index.js but NOT if you are running it using npm start (node index.js start script).
Both #Michal Kapracki and #Avik was hinting at this (I missed the missing env variables when comparing the first time)
What I did to solve it was similar to the dyld: Library not loaded ... Reason: Image not found question as #Avik linked, I had to add a bunch of libraries which were dependent (that was automatically resolved before) and a post_install.sh script which uses the install_name_tool to change the #rpaths to the correct path.
It's a pretty ugly solution https://github.com/klintan/rosbag2_nodejs/blob/master/post_install.sh but it works.
Only for Mac though, so needs to be generalized.
So in summary what I think is the issue:
NPM for some reason can't use or removes the env variable DYLD_LIBRARY_PATH which is used to search for dynamically linked libraries during runtime. This makes it necessary to link these manually using the mac tool install_name_tool.
Would it be possible to get an explanation of how npm start works?
I have an Angular 2 application written in Typescript. I enter npm start in the console and this both compiles and launches the application using Node's built in web server.
However what is the starting point for this? Which files does the npm start command read in order to compile and start the application? Also why do I use npm start and not e.g. node start? I understood that NPM was just the package manager for node itself.
What I understand so far:
I have a tsconfig.js file which tells the TypeScript compiler what to do.
I have a packages.json file which tells node which packages to download.
Where do the following files fit into this:
main.ts
app/app.module.ts - which I understand is the starting point for my application.
How do all of these components fit together to form the application?
npm start is just an alias for npm run start, which runs whatever command is in scripts.start in your package.json.
It neither knows nor cares about TypeScript, or Angular, or anything like that - it just executes whatever script it's given on the command line.
I'm running into an issue using Sails.js framework (node.js).
It seems like it runs automatically grunt when the server starts. But I don't want that. In order to prevent this, it is possible to configure in a .sailsrc file that we don't want grunt to start. (http://www.sailsjs.org/documentation/concepts/assets/disabling-grunt)
But this specific configuration file is only taken into account when we run the server using sails lift command. It won't be used if we use node app.js.
Point is, I want to use forever with sails. But I don't know how to run forever and take into account the .sailsrc file so that Sails doesn't start grunt on its own.
I'm using BrowserSync and I need to startup things in a really specific order, it works fine when using sails lift and grunt separately, but I don't get any hot refresh that way.
I found a similar issue here, but it doesn't help me much. Error when use forever in sails
I assume you get the "Your .sailsrc file(s) will be ignored." error.
Running npm install rc --save in both the project root directory and node_modules/sails, and adding
"hooks": {
"grunt": false
}
to .sailsrc solved this issue for me.
Update: if you're using an older version of Sails, such as sails#0.10.5 you have to change the line "rc": "^0.5.5” to "rc": "^0.5.0" in node_modules/sails/package.json, remove rc and reinstall it with the older version of rc (which is used in the newer versions of Sails).
In the sails book from Manning:
Note: Grunt is also optional. If for some reason you enjoy doing manual repetitive tasks simply delete the Gruntfile.js from the root of your project. No more Grunt. When you restart Sails via sails lift warnings that the “Gruntfile could not be found” and that “no grunt tasks will be run” are displayed.
Give that a shot
Setting hooks.grunt = false keeps being valid for Sails v1.x
I am new to node. I am trying to run an express server. I get no errors when installing express but when i run npm start or node app (as all the beginner tutorials point) nothing seems to be happening. The only way i can start the server is by typing node /bin/www. My operating system is Windows. Any advice?
The Express scaffold script generates a package.json file with a start script field that points to the app.js file it also created. Since Express 4 was released the scaffold generator script has been moved to its own package. https://github.com/expressjs/generator
All npm start does is look in the package.json file for a starting script to pass to node. You can see this in the documentation.
Running npm start with a package.json like this:
"scripts": {
"start": "app.js"
}
Is exactly equivalent to running node app.js.
I managed to solve my issue by changing the code page of cmd-dos. By using chcp 850 or chcp 65001 in cmd thus changing codepage to latin - utf8 the issue is gone.
I'm a real noob at this. I've just began scratching the surface on node.js/socket.io/html5 and stuff. I finally figured out how to use my command prompt (using windows) to launch a "hello world" application with the command "node example.js." But what does npm mean? When I'm looking at socket.io it says to install, npm install socket.io Does that mean I need to extract all the files into my nodejs folder?
I'm confused.
npm is a generally awesome program for managing packages and dependencies (especially while you have a network connection). It does lots of fancy things and is most commonly used with node.js projects. That said, it's an unfortunately common misconception that the acronym stands for "node package manager".
In reality, npm doesn't actually stand for anything as it's not an acronym. With taglines like "no problem, meatbag" the npm organization playfully resists the trend of acronymization. It should always be referenced in lowercase to avoid confusion with the National Association of Pastoral Musicians.
npm is a command line interface program to manage node.js libraries (it stands for node package manager - at least it did initially, they since turned this into a bit of a running gag - thanks to #spex in the comments for that link). Check out the docs, it is awesome and amazing. As you mentioned, just type npm install in a command prompt, and voilà, you have the library in your local node modules.
npm is stands for Non-Parametric Mapping utility written by Chris Rorden...
But we can keep it as Node Package Manager and it is very helpful for Module Loader which uses CommmonJS module pattern, and I am not sure will Node will support the ES2015 Module Loading Syntax (Built in module Loading Syntax)?
for those who are wondering the same thing, you just type npm install socket.io in the command prompt where nodejs file is.
C:/Program Files/nodejs
That should be what your command prompt should say and then just type that in.