Elastic Beanstalk npm failing - amazon-elastic-beanstalk

I am trying to upload my app to Elastic Beanstalk but the npm install is failing on node-pre-gyp install --fallback-to-build. I have tried various versions of node with no avail. It seems to be trying to get a package for linux which doesn't exist and is not needed, it is only needed for OSX (in which it is working fine).
The solution seems to be to run npm install with the --no-optional flag but I can't find a way to make EB run install with this flag.
Also this package seems to be a dependency for karma, which I only have as a dev dependency in my package.json file. I can see EB is installing using the --production flag so I don't know what it's trying to install it in the first place.
Any ideas on how to work around this issue would be much appreciated.
> Running npm with --production flag
> 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
> subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v4.6.1-linux-x64/bin/npm',
> '--production', 'rebuild']' returned non-zero exit status 1
> (ElasticBeanstalk::ExternalInvocationError)
> caused by: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
> npm WARN package.json Room#1.0.0 No repository field.
> npm WARN package.json Room#1.0.0 No README data
> npm WARN package.json Room#1.0.0 No license field.
>
> > uglifyjs-webpack-plugin#0.2.1 postinstall /tmp/deployment/application/node_modules/uglifyjs-webpack-plugin
> > node lib/post_install.js
>
>
> > fsevents#1.0.15 install /tmp/deployment/application/node_modules/karma/node_modules/chokidar/node_modules/fsevents
> > node-pre-gyp install --fallback-to-build
>
> node-pre-gyp ERR! Tried to download: https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.0.15/fse-v1.0.15-node-v46-linux-x64.tar.gz

I got similar kind of error as fallows
When I looked at more details section I found this ,where it was an error in the bcrypt library
So I removed that library and installed bcryptjs library and deployed it again ,then it was successful deployed. So this kind of errors may appear when there are deprecated libraries and not supportive libraries .

If anyone else comes across this, my problem was in my .gitignore I had node_modules rather than node_modules/ and the folder was getting tracked and deployed. Removing the node_modules folder from the deployment solved the issue.

First, check your log by going to
Go to Elastic Beanstalk.
Click on your app's environment name
Select Logs on the sidebar
Click on Request Logs and select Last 100 Lines or Full Log.
From your log, you will see why npm is failing
Time to fix it!
if it is related to gyp WARN, gyp WARN EACCESS or gyp ERR, then create a file called .npmrc in the root directory of your project. In this file, add unsafe-perm=true. This will force npm to run node-gyp as root.
if the error is related to a particular npm package failing to install, kindly consider an alternative to that package.
All the best !!

Related

Build Failure for Django-Oscar 3.1.6 Frobshop Assets

I am working through the Frobshop sample project for django-oscar.
The django-oscar documentation is rather terse regarding customizing assets, and the unresolved bug I reported for manage.py oscar_fork_statics just adds to the confusion. This is my (failed) attempt at copying files manually and compiling the assets.
I installed Frobshop in /var/work/django/frobshop/.
I installed a virtual environment for django-oscar in /var/work/django/oscar/, so the asset directory for the distribution is found within that directory, in lib/python3.8/site-packages/oscar/static/oscar/. The README.rst file in that directory said When building your own project, it is not recommended to use these files straight from the package. Rather, you should take a static copy of the ``oscar/static/oscar`` folder and commit it into your project.
Seemed straightforward, so I typed:
$ cd /var/work/django
$ mkdir frobshop/frobshop/static/
$ cp -a lib/python3.8/site-packages/oscar/static/oscar/* frobshop/frobshop/static/
Next, README.rst said: You can compile the static assets from the root of the project using a make target: make assets.
$ make assets
make: *** No rule to make target 'assets'. Stop.
Hmm, that did not work. Is https://github.com/django-oscar/django-oscar/blob/master/Makefile the proper Makefile, I wonder, and where should it be located?
$ wget -O frobshop/static/Makefile \
https://raw.githubusercontent.com/django-oscar/django-oscar/master/Makefile
Running make assets gave me an error message complaining about a missing package.json, so I grabbed it from django-oscar also.
$ wget -O frobshop/static/package.json \
https://raw.githubusercontent.com/django-oscar/django-oscar/master/package.json
Seemed like I should run make from the new frobshop/frobshop/static/ directory:
$ (cd frobshop/static/; make assets)
Many files were installed, then eventually this message appeared:
found 3 vulnerabilities (2 moderate, 1 high)
run `npm audit fix` to fix them, or `npm audit` for details
npm run build
> django-oscar#3.0.0 build /var/work/django/frobshopCamille/frobshop/static
> gulp copy && gulp scss
[11:32:39] No gulpfile found
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! django-oscar#3.0.0 build: `gulp copy && gulp scss`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the django-oscar#3.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/mslinn/.npm/_logs/2021-02-19T16_32_39_097Z-debug.log
make: *** [Makefile:29: assets] Error 1
I do not know what to do with that error. I see a directory in django-oscar called gulpfile.js. Should I copy that somewhere also?
README.rst went on to say: If you make changes to Oscar's assets in development, you can run ``npm run watch`` to automatically watch and compile changes to them.
$ (cd frobshop/static/; npm run watch)
Of course, that just yields the same error message as before.
The instructions for compiling assets (using make assets, which runs Gulp tasks) mentioned in src/oscar/static_src/oscar/README.rst are actually only meant for when developing/packaging django-oscar itself. We will try to make the documentation more clear.
For a project/shop based on django-oscar, you only need to run ./manage.py collectstatic, to use Oscar's static files without modification, as mentioned here: https://django-oscar.readthedocs.io/en/latest/howto/how_to_handle_statics.html#customising-statics
To modify and override Oscar's static files, you in addition need to run ./manage.py oscar_fork_statics, to copy Oscar's static files into your project. The command is currently broken, but we are working on a fix: https://github.com/django-oscar/django-oscar/pull/3657

npm start not working for react while install react script (react script : 3.4.0 version)

I am new to React js, While using npm start after install the react not working,I tried every process but no use. Thanks in advance
Error
cricdost#0.1.0 start C:\xampp\htdocs\cd-web
react-scripts start
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"webpack": "4.41.2"
Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:
C:\xampp\htdocs\node_modules\webpack (version: 4.39.2)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
Delete node_modules in your project folder.
Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
Check if C:\xampp\htdocs\node_modules\webpack is outside your project directory.
For example, you might have accidentally installed something in your home folder.
Try running npm ls webpack in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed webpack.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cricdost#0.1.0 start: react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cricdost#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\XSC-10261\AppData\Roaming\npm-cache_logs\2020-02-20T04_56_31_650Z-debug.log
I had faced the same error. The solution that I found is to do the step-6 as described in Error message. That is to delete "webpack" folder of node_module folder under your root projects directory. For example
Assume that you installed "npm install create-react-app" in D:\Projects folder.
And then you ran "npx create-react-app firstproject" in D:\Projects folder. So, your actual react project folder is "D:\Projects\firstproject".
So, what I want to tell is don't delete "webpack" folder in "D:\Projects\firstproject\node_module" directory. Instead, delete "webpack" folder in "D:\Projects\node_module" directory.
And then, you can run "npm start" command in your actual react project directory "D:\Projects\firstproject".
I hope, this will work for you.

Could not find a required file. Name: index.html

I have been working on this React project, since a few months without having come across this error. I haven't made any changes in the location of the index.html file in the project tree, which is why I can't explain this error.
I have tried the following measures without success:
changing the location of public folder
changing the location of contents of public folder
changing the location of package-lock.json
changing the location of package.json
npm install
npm install react-scripts --save
Please find the error displayed in the terminal:
Could not find a required file.
Name: index.html
Searched in: /Users/Sujay/Documents/Documents/Learn Web Development the Hard Way/lacapsule/project/Dark Sky Map Bitbucket/darkskymap_frontend/public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the frontend#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Sujay/.npm/_logs/2019-08-06T07_12_22_366Z-debug.log
Expected result : React project should launch without any issue.
Actual result: Error message in terminal mentioned above.
index.html has been moved/removed from the /public directory
Does your project have an index.html file in the public directory?
If not you can get the one that Create React App uses here
It should be in <your project root>/public/index.html
If you are using Git for version control it will be able to tell you if something was moved or removed.
Run git status to view changed files
Your public folder might be missing, just create another app using create-react-app and copy paste the public folder in this directory
I had the exact same problem. Both my package-lock and package.json were outside of the root folder. Once I moved them into the root folder it started up just fine.
In my case, I have accidentally deleted the public directory so it couldn't find the index.html file

How do I make my repository a dependency in package.json and have it prompt me for my information?

I want to put my one of my own repositories as a dependency to a project I am working on. Right now I am using NPM link to do that.
Also, I'd like it to prompt me for my username and password instead of putting that
kind of data in my repository when I use npm install. How do I do that? It doesn't do that now.
I want the content of the repository to show up as their own folder
The problem is when I run npm install it gives me a bunch of error messages from NPM. So I've tried two things. First I tried cloning a public repo from github:
Public Repo Github
SO in package.json, I used the ssh like this:
"dependencies": {
"repo_name": "git#github.com:ownername/reponame.git#84876fa5aasf55fssfsfafsa"
},
^Note that data is fake. The # is a commit hash.
It gave me this error when I ran npm install:
Warning: Permanently added the RSA host key for IP address '$IPADDRESS' to the list of known hosts.
Permission denied (publickey)
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Code 128
Then I tried HTTPS, again with a commit hash:
"dependencies": {
"repo_name": "https://github.com/ownername/reponame.git#84876fa5aasf55fssfsfafsa"
},
It worked.....kind of. It seemed to install all the depencies from the repo in the link
but didn't clone the repo in the link to repo_name, it didn't seem to clone anything.
So I decided to try a different repo. One without any dependencies of its own. I used the HTTPS....
it didn't work.
I got these errors:
npm ERR! addLocal Could not install /tmp/npm-11929-4791330b/git-cache-2278328b/38b944c916c18cd4e004f07f2f476a4bb393ff8e
npm ERR! Linux 4.8.0-58-generic
npm ERR! argv "$nodepathname" "$npmpathname" "install"
npm ERR! node v7.0.0
npm ERR! npm v3.10.8
npm ERR! code EISDIR
npm ERR! errno -21
npm ERR! syscall read
npm ERR! eisdir EISDIR: illegal operation on a directory, read
npm ERR! eisdir This is most likely not a problem with npm itself
npm ERR! eisdir and is related to npm not being able to find a package.json in
npm ERR! eisdir a package you are trying to install.
Private Repository Bitbucket
When I try my private repository via ssh via provided bitbucket string (with a commit hash), it gives me similar error messages with the other repository, it tells me:
Please make sure you have the correct access rights
npm ERR! code 128
npm ERR! Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
It doesn't prompt me for a username or password.
Using https on the private repo (with a commit hash, similar as before) gives me a similar error without prompting me with any username:
remote: Invalid username or password. If you log in via a third party service you must ensure you have an account password set in your account profile.
npm ERR! code 128
You could use the postinstall hook to initiate the Git clone after npm install:
"scripts": {
"postinstall": "git clone ... node_modules/..."
}
There is no way for npm to prompt for a username or password. Its just not designed to work that way. There is a couple ways to make what your doing work.
1) generate a ssh key(if you haven't already) and add it to your bitbucket.
2) make the private package public(ie open source it)
3) pay for private npm packages and publish a private npm module.
4) make a public npm package if your making open source project. You can still use npm link to link the project to the secondary project to test the packages before publishing. The dependency will be linked based on your not the folder name.
Option 1 and 2 are generally not recommended though. Not using an npm package kind of defeats the purpose of using npm at all. You should try to avoid linking to github directly unless there are extenuating circumstances such as you needed to fork a no longer maintained project and change code.
If you are just trying to avoid paying for private npm modules, personally I would not bother separating out the applications logic into different packages.
Just to all kind of expound. Maybe you are trying to create a module and have never done so before so I will explain that as well. If you have a private or public application (not an npm module, and you are trying to create a public open source npm module and link to it.)
Lets say you have the two folders.
/git/my_application
/git/my_new_npm_module
and your new npm module has the package name "new-module" in package.json. In order to use that in your my_application app, you would need to enter that directory and run npm link on your npm module
cd /git/my_application
npm link ../my_new_npm_module
now within any node file in your my_application app, you can use require('new-module'); to access what is exported from your new npm module.
when your ready to make your package public you simply need to update the version tag in the new modules package.json and type
npm publish
After googling about the specific problem, I found the following link.
link

Azure Website Instance not running defined Node Version in Package.json

Currently in Azure I am utilizing a 'Azure Website' instance to try and run Docpad (NodeJS App). Within my package.json file I have the following defined..
"engines": {
"node": "0.10.21",
"npm": "1.x"
},
I have tried numerous different entries, from 0.10.x to 0.8.x all listed here => http://azure.microsoft.com/en-us/documentation/articles/nodejs-specify-node-version-azure-apps/
The problem is that Docpad is using Dependencies with Semver Entries and Azure seems to be ignoring my defined Node version entirely, as there are errors such as...
npm WARN engine docpad#6.69.2: wanted: {"node":">=0.8","npm":">=1.2"} (current: {"node":"0.6.20","npm":"1.1.37"})
Because of this, I am getting critical/failure errors when NPM goes to install Docpad due to dependencies such as this...
npm ERR! Error: No compatible version found: rimraf#'^2.2.8'
npm ERR! Valid install targets:
npm ERR! ["1.0.0","1.0.1","1.0.2","1.0.4","1.0.5","1.0.6","1.0.7","1.0.8","1.0.9","2.0.0","2.0.1","2.0.2","2.0.3","2.1.0","2.1.1","2.1.2","2.1.3","2.1.4","2.2.0","2.2.1","2.2.2","2.2.3","2.2.4","2.2.5","2.2.6","2.2.8"]
I have even gone as far as to try printing the Node Version in my deployment script, only to have it return the Environment Variable Azure supposedly honors, but it is clearly invalid.
All I am trying to do is deploy a Docpad website on Azure and I am dumbfounded as to how this is so difficult to to just use a semi-recent version of node in Azure. Any help at all would be greatly appreciated!
node and npm are now npm packages that can be installed as dependencies of your project, so it will run with the correct versions once its dependencies are installed.
However, to install those packages you will need to start with newer versions than the ones you have in your engines section:
Without npm >= 3 installing the node package will break your system by removing the existing version of node too soon
Without node >= 4 the npm package won't work (it isn't specific as to what goes wrong)