Issue installing hiredis on AWS Linux using OpsWorks - node.js

I'm using OpsWorks to deploy my custom node.js application. I'm not a Chef expert and thought this would be an easy process however I keep hitting snags. This most recent issue is really setting me back.
Basically I'm using a package called "Kue" which depends on a Node package called Hiredis. Hiredis is implemented at the C-level (as far as I understand) and uses some Python level compilation tools.
It seems that the default Chef script that OpsWorks uses keeps failing at the point where Kue then Hiredis is being installed. The following is the log when the instance attempts deploying the application: http://codepad.org/RXxKXqBq
Upon Googling some people are indicating its an issue with the Python version that AWS Linux is using. Note that I'm using the default Node.js application Chef recipes which can be found here: https://github.com/aws/opsworks-cookbooks/tree/release-chef-11.10/opsworks_nodejs

I'm not that familiar with node packages and version compabylity but from log that you have shared it seems it's problem in one of the node packages that you're using called amdefine:
npm ERR! Failed to parse json
npm ERR! Unexpected end of input
npm ERR! File: /home/deploy/.npm/amdefine/0.1.0/package/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse
npm ERR! System Linux 3.14.26-24.46.amzn1.x86_64
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--production"
npm ERR! cwd /srv/www/my_api/releases/20141214002817
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! file /home/deploy/.npm/amdefine/0.1.0/package/package.json
It can be fixed by npm cache clean or by changing version of nodejs, as you found too probably.
For adding command npm cache clean you must create new recipe or add it to your wrapper cookbook. Only thing that should be satisfied is that this command should be after installing node and before installing packages.
If yo want to change version, you can chceck default nodejs recepie you can see that requred version of installed nodejs is definded in attributes file for that cookbook.
So you can override default value with default[:opsworks_nodejs][:version] attribute.

Related

my npm commands aren't working, npm is bugging?

C:\Users\jason\OneDrive\Documents\Web-Dev-Projects\pinterest-clone>npm install
npm ERR! Windows_NT 10.0.19042
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\jason\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v14.17.6
npm ERR! npm v3.10.10
npm ERR! cb.apply is not a function
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\jason\OneDrive\Documents\Web-Dev-Projects\pinterest-clone\npm-debug.log
I am getting this really annoying error that doesn't even tell me what's wrong with npm. I tried deleting and installing node.js again and running the command npm install but I would still get the error. I even tried running a command to use the latest version of npm and it still wouldn't work (npm install -g npm-windows-upgrade & npm-windows-upgrade).
It seems like npm is just being very buggy and doesn't want to work. Help please.
Based on this very similar issue, you really shouldn't be using npm 3.x with Node 14.
You might want to uninstall Node, ensure there are no traces of Node or npm on your system, then reinstall Node 14 or 16.
They automatically install newer versions of npm (6 or newer).
Also, the npm-windows-upgrade package you mention hasn't been updated in 3 years. Maybe don't use it?
You are definitely not running the latest version of the tools. NPM is in v7 and Node.js is in v16. Uninstall what you have currently installed, and download the latest version (make sure to choose Current not LTS) to install the latest version. Here is the link
I'd switch to a package manager specifically for managing different versions of Node + NPM side-by-side on your machine, which saves you the hassle of having to have 1 global installation that just "has to work" for all your projects.
Linux has nvm (node version manager). Since you're on Windows, you might want to check out the Windows-"fork": https://github.com/coreybutler/nvm-windows.
It should prevent incompatible versions of node and npm being installed together.

NPM Install Error - Node-Pre-Gyp

When I try to run npm-install I get:
npm ERR! Windows_NT 6.3.9600 npm ERR! argv "C:\Program Files
(x86)\nodejs\node.exe" "C:\Program Files (x8
6)\nodejs\node_modules\npm\bin\npm-cli.js" "install" npm ERR!
node v4.0.0 npm ERR! npm v2.14.2 npm ERR! code ELIFECYCLE
npm ERR! v8-debug#0.4.6 install: node-pre-gyp install
--fallback-to-build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the v8-debug#0.4.6 install script 'node-pre-gyp install --fal
lback-to-build'. npm ERR! This is most likely a problem with the
v8-debug package, npm ERR! not with npm itself. npm ERR! Tell the
author that this fails on your system: npm ERR! node-pre-gyp
install --fallback-to-build npm ERR! You can get their info via: npm
ERR! npm owner ls v8-debug npm ERR! There is likely additional
logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:_Src\Personal\rzaleski\ILikeThis\npm-debug.log
I tried a number of things (installing VS C++ redistrib, npm install --msvs_version=2013, etc). Nothing seems to work.
Do you have any ideas how I can find out the actual error (the log is a bit daunting).
UPDATE: What I ended up doing was reverting from Node v4.0.0 to NODE v0.12. This is not really a fix to the issue, but it got me around my issues.
Go to: (http://www.devdocs.io) look # the npm section. Must use desktop, must use windows if possible (Mac layout is weird for some reason) Follow the steps detailed for "resetting npm cache"
Node-gyp is a P.I.T.A. and often blows up installs among other things. I have a horrible time with it every time I come back to an environment I haven't used in a while and try to use it again.
Alternatively, you can uninstall node, and attempt to reinstall using chocolatey if you're on windows or brew if you're on a mac. Make sure you sudo commands when installing to mac.
You're most likely going to have to clean out the npm cache, possibly reinstall nodejs, and possibly reinstall node-gyp.
NOTE: Before you go about the above mentioned steps, first make sure that your configurations are compatible, including your python version for node-gyp. (https://www.npmjs.com/package/node-gyp) Also, I have solved the C++ redistributable issues several times without touching anything C++ related, just so you know this error is not indicative of C++, but rather local settings and compatible software versions that interact with node + npm NOT C++ related (for instance, your python version interacting with node-gyp)
There is no straightforward "run this and that" to fix, you kind of have to muddle through it, and I can promise you that you'll have to do it more than once. But the more you fix node + npm + node-gyp, the more able you will be to quickly remedy all issues in the future. The links above should sort you out no problem though. Just walk through them slowly and thoroughly as instructed.
All i did is uninstall node and install it again, and during the installation, check the box telling you to install the needed dependencies and complete your installation.
If it persists, locate the package that is causing this error and install it seperately.
Example:
npm install -g node-gyp
npm install bcrypt

‘node-gyp rebuild’ installation error when adding a package to meteor app in Windows 7

I was trying to add a package (mizzao:turkserver) to my Meteor application, but I kept getting this error:
mizzao:turkserver: updating npm dependencies -- request, libxmljs,
validator, querystring, async, deepmerge...
gypnpm ERR! Windows_NT 6.1.7601
npm ERR! argv
"C:\\Users\\PC4all\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.1.3\\mt-os
.windows.x86_32\\dev_bundle\\bin\\\\node.exe"
"C:\\Users\\PC4all\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.1.3\\mt-os
.windows.x86_32\\dev_bundle\\bin\\node_modules\\npm\\bin\\npm-cli.js"
"install" "libxmljs#0.8.1"
npm ERR! node v0.10.36
npm ERR! npm v2.7.3
npm ERR! code ELIFECYCLE
npm ERR! libxmljs#0.8.1 install: `node-gyp rebuild`
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the libxmljs#0.8.1 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the libxmljs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls libxmljs
npm ERR! There is likely additional logging output above.
=> Babel active on file extensions: es6.js, es6, jsx
=> Errors while adding packages:
While building package mizzao:turkserver:
error: couldn't install npm package
I am developing my Meteor application on a Windows 7 machine and from what I have been able to gather from posts on forums, the error seems to be related to that fact (interaction between npm and Windows - I did not find any posts describing the same problem on Linux machines).
I've already tried installing the latest Python version and MS Visual Studio 2013 as suggested here: https://github.com/TooTallNate/node-gyp#installation, as well as setting some environment variables as suggested here: https://github.com/atom/atom/issues/2754. But none of those helped.
Any help would be greatly appreciated!
As I described in this comment, this seems to be an issue with the Python path being set incorrectly for npm, as Meteor's distribution of npm isn't hooking it up correctly. Most Linux distros come with Python, but Windows doesn't, so it is correlated with running Windows.
It can be fixed by making sure that Python is installed, then running the following command:
npm config set python C:\Python27\python.exe
The use of an old libxmljs is because mizzao:turkserver is dependent on a relatively old node MTurk API, which I'd like to wean it off of at some point, but isn't such a high priority at the moment.
See also:
https://github.com/lovell/sharp/issues/163
https://www.robertkehoe.com/2015/03/fix-node-gyp-rebuild-error-on-windows/

What does the ELIFECYCLE Node.js error mean?

What does ELIFECYCLE mean?
Here's my app code: https://gist.github.com/samholmes/388ca4552c5936b52c5d
When I run the 'blast-emails' command, it will run for a while until shortly crashing with the error:
npm ERR! Linux 3.2.0-4-amd64
npm ERR! argv "/root/.nvm/versions/io.js/v1.6.1/bin/iojs" "/root/.nvm/versions/io.js/v1.6.1/bin/npm" "run" "live"
npm ERR! node v1.6.1
npm ERR! npm v2.7.1
npm ERR! code ELIFECYCLE
npm ERR! emailer#0.0.0 live: `NODE_ENV=production node app.js`
npm ERR! Exit status 137
npm ERR!
npm ERR! Failed at the emailer#0.0.0 live script 'NODE_ENV=production node app.js'.
npm ERR! This is most likely a problem with the emailer package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! NODE_ENV=production node app.js
npm ERR! You can get their info via:
npm ERR! npm owner ls emailer
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /apps/emailer/npm-debug.log
The npm-debug.log file is also included in the gist.
I'm looking for one of two answers: What does ELIFECYCLE mean? (or) Why am I getting the error in my application code?
It's basically saying it fails to spawn your process not due to permission but to an error in your script. Source
You don't have any problem executing NODE_ENV=production node app.js ?
One might think this is because outdated versions of npm and node, but it's not the case.
Just as Pierre Inglebert says, if you look into the source you can see that End of lifecycle means the program unexpectedly stopped. This can have various reasons. So it's not a syntax error and not an expected exception/error.
The error appeared to me when a different tool was already using the http port (3000) defined in my node scripts. When you run your node app on port 80, make sure you have stopped Apache webserver (as an example).
In my case, it was because of low RAM memory, when a photo compression library was unable to process bigger photos.
While working on a WordPress theme, I got the same ELIFECYCLE error with slightly different output:
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/Cellar/node/7.6.0/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v7.6.0
npm ERR! npm v3.7.3
npm ERR! code ELIFECYCLE
npm ERR! foundationsix#1.0.0 postinstall: `bower install && gulp build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the foundationsix#1.0.0 postinstall script 'bower install && gulp build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the foundationsix package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! bower install && gulp build
After trying npm install one more time with the same result, I tried bower install. When that was successful I tried gulp build and that also worked.
Everything is working just fine now. No idea why running each command separately worked when && failed but maybe someone else will find this answer useful.
If you came here like I did, after receiving a similar error when trying the React Getting Started guide, you might like to know that the problem could have been caused by not having installed Watchman. Download it here, or install it with Homebrew with brew install watchman and try again: https://facebook.github.io/watchman/docs/install.html
PS: You might want to do a brew update first.
When running Webpack build I was getting similar error because node doesn't understand async await keywords on older versions. I added webpack babel-plugin-transform-async-to-generator and it was solved. This replaces them with promises.
at process._tickCallback (internal/process/next_tick.js:10
4:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ng-contact-manager#0.0.0 sample: `node src/server/dat
a/seed-db.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ng-contact-manager#0.0.0 sample script.
npm ERR! This is probably not a problem with npm. There is lik
ely additional logging output above.
npm ERR! A complete log of this run can be found in:
I have the same issue here is how I got solved finally!
the error:
my error from the terminal when i run npm run sample
after correcting my database connection username and password
I was using mlab for my database and under the file .env i forget to properly put the user name and password. When I correct that I works.
> ng-contact-manager#0.0.0 sample /Users/mohammedr.kemal/Downl
oads/Ex_Files_ANGULAR_API_AUTH/Exercise Files/Ch01/01_04/start
> node src/server/data/seed-db.js
connected to mongodb...
connected to mongodb...
2 records inserted.
closing connection...
done.
12 records inserted.
closing connection...
done.
So it might be good to look any data connection we made in our code if we have.
I had the same error after I installed new packages or updated them:
...
npm ERR! code ELIFECYCLE
npm ERR! errno 1
...
It helped me to run installation command once again or a couple of times.
After that, the error disappeared.
I had this issue when I was running two projects that had the same set up and I already had one running. This meant that the other project couldn't use that port number. As soon as I stopped the other project running I had no issues.
This issue can also occur when you pull code from git and not yet installed node modules "npm install".
The Windows solution is the same as the Linux sudo answer. Run the npm start (or whatever) as Administrator. I had added a new module to my project. Worked on some machines but on others that were more locked down, not so much. Took a while to figure it out but the new module needed access to "something" that wasn't available without administrator permissions.
I had the same error code when I was running npm run build inside node docker container.
Locally it was working while inside a container I had set option to throw error when there is a warning during compilation while locally it wasn't set. So this error can mean anything that is connected with stopping the process being done by NPM
In my case I generated a similar error when I copied the project over from another directory. some hidden files, like the critical .babelrc, were missing. SO ahhh... make sure you copy all the files!
:)
For me it was a ternary statement:
It was complaining about this line in particular, about the semicolon:
let num_coin = val.num_coin ? val.num_coin || 2;
I changed it to:
let num_coin = val.num_coin || 2;
Likewise, I saw this error as a result of too little RAM. I cranked up the RAM on the VM and the error disappeared.
I found the solution here - https://javahowtos.com/guides/124-docker/418-npm-exit-status-137-when-building-a-docker-image.html
It says - The cause of this specific npm error status usually means that Docker is going out of memory. So, when this happens, the Linux kernel just kills the process.
if you are running on ubuntu, please check your nodejs version. please update the version to the latest and clear the cache and reinstall the modules (npm install) and build.
or otherwise
please upgrade your RAM size and try again. it'll work sure.
First, you will have to remove the npm cache and upgrade to the latest version of the node and npm will resolve the issue.
sudo npm cache clean -f
sudo npm install -g n install n
sudo n stable
The first command will force clean the npm package manager's cache, After the second and third commands, a stable version of the node and npm will be installed. then you can execute npm i and npm run build for creating an optimized production build.
This solution worked for the same error on the npm run build command in nextjs.

Publish development version of NPM package

How can I publish development version of NPM package?
I tried to set "dev" value for version field in package.json but I got an error when publishing it:
$ npm publish
npm ERR! Error: Invalid version: "dev"
npm ERR! at Object.module.exports.fixVersionField (/usr/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js:180:13)
npm ERR! at /usr/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js:29:38
npm ERR! at Array.forEach (native)
npm ERR! at normalize (/usr/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js:28:15)
npm ERR! at final (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:310:33)
npm ERR! at then (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:124:33)
npm ERR! at /usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:299:40
npm ERR! at fs.js:266:14
npm ERR! at /usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:103:5
npm ERR! at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! System Linux 3.11.0-15-generic
npm ERR! command "node" "/usr/bin/npm" "publish"
npm ERR! cwd /home/ionicabizau/package-name
npm ERR! node -v v0.10.24
npm ERR! npm -v 1.3.23
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/ionicabizau/package-name/npm-debug.log
npm ERR! not ok code 0
Which are the closest alternatives?
You can upload prerelease tags to npm. These tags will not be matched by normal semver range semantics, but will allow you to both use and upload development versions. An example would be 1.3.5-alpha.3. If you're uploading something that has no version yet, then a reasonable use would be something like 0.0.1-alpha.1.
NPM package version must meet requirements of semver
A normal version number MUST take the form X.Y.Z where X, Y, and Z are
non-negative integers, and MUST NOT contain leading zeroes. X is the
major version, Y is the minor version, and Z is the patch version.
Each element MUST increase numerically. For instance: 1.9.0 -> 1.10.0
-> 1.11.0.
So using dev as a version number is not allowed.
Also it is not recommended to publish any code which is in development state. If you want to test your module within different module you can include that module using relative path or using git remote URL.
Example:
Let's say that the module which you are developing is called foo and you would like to test it in module bar, script file bar/index.js. Let's assume both module directories are in the same parent directory. Instead of publishing unfinished module foo to npm and install it in module bar, you can do as follows:
var foo = require('../foo')
As suggested by Ionicã Bizãu (comments below), you can also use npm install with git remote URL e.g.
npm install <git remote url>
NPM install documentation provides more details (option g) on that installation method.
Alternatively you can use approach proposed in this post: Locally test your npm modules without publishing them to npmjs.org.
EDIT
There is another alternative solution which require npm link command:
Execute npm link command inside your developed module. That will create globally-installed symbolic link from prefix/package-name to the current folder
Another step is to execute npm link package-name (where package-name is a name of your developed package) in some other location (other module / application which you use to test the developed module). That will create a symlink from the local node_modules folder to the global symlink (which was created in the first step).
Note that you may need to run the first command as a privileged user (usually sudo helps) in some operating systems.
With symlinks in place you will be able to add changes to your developed module and see their results instantly in other linked modules.
I hope that will help.

Resources