npm ERR! code E404
npm ERR! 404 Not Found: event-stream@https://registry.npmjs.org/event-stream/-/event-stream-3.3.6.tgz
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/.npm/_logs/2019-02-02T01_46_34_063Z-debug.log
Failed to run npm install. Snapshot logs for more details.
No environment variable EB_EVENT_FILE found. Writing message to stderr.
Msg: Failed to run npm install. Snapshot logs for more details.
Traceback (most recent call last):
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 695, in <module>
main()
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 677, in main
node_version_manager.run_npm_install(options.app_path)
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 136, in run_npm_install
self.npm_install(bin_path, self.config_manager.get_container_config('app_staging_dir'))
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install
raise e
If you see an error like this, it means that EB is trying to install a package which doesn't exist. You can check by visiting the package version url, in this case: https://registry.npmjs.org/event-stream/-/event-stream-3.3.6.tgz
Some people suggest simply rm -rf node_modules
locally and then re eb deploy
. This didn't work for me.
So I tried to find which of my npm modules were using the invalid package. A simple file search wasn't too helpful, so I ran
npm ls event-stream
This showed that three of my modules were using event stream and two of them were wanting that old version 3.3.6 whcih was a 404 on npmjs.org.
So I fixed that - in my case by removing the entries from my package.json since I wasn't using them in this project. In other cases, you may need to fork the module, or submit a PR to the author - or fix and use link maybe. I was lucky.
Now, I redeployed and the issue persisted on the server.
To find out why, I eb ssh
'd and ran the same command npm ls event-stream
(see command below for how to actually do this on the server) the same packages were shown, so I did the same thing I did locally, removed them, and re-installed.
To re-install on eb, use this command:
sudo /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install 2
PS in eb, your node file is at
cd /tmp/deployment/application
If you want to make an alias for node, and then run npm yourself you can do:
# Find Node and make an alias
sudo ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node
# Use NPM
# format: node /path/to/npm.js [action]
# (this only works if you alias node)
node /opt/elasticbeanstalk/node-install/node-v8.11.4-linux-x64/lib/node_modules/npm/bin/npm-cli.js ls event-stream
Now I saw that even though I'd removed the offending packages, I could still see those two requiring the invalid versions.
I went into my EB Web Interface and checked that the application version didn't include them, and it didn't - so where were they still coming from??
I didn't know or care - at this point I could tell the package.json was correct on EB and commited locally - so I simply rebuilt the environment
This worked, since the application version was correct and excluded the offending package (which were old nodemon and npm-run-all) and wherever those still were in the fs, EB Rebuild blasted them out for good.