Malformed bower.json file - json

I have the latest version of Bower installed. I am trying the command
bower register flatly-3 https://github.com/brandonjschwartz/bower-bootswatch-flatly.git
Bower has the error message that the bower.json file is malformed due to an unexpected string. I have tried a number of different things (punctuation etc) but get the same error... Any help is greatly appreciated

Bower is attempting to get tag 3.0.0 from your repo:
https://github.com/brandonjschwartz/bower-bootswatch-flatly/releases/tag/3.0.0
The bower.json from that release does have some issues:
{
"name": "bower-bootswatch-flatly",
"version": "2.3.2",
"main": "less/flatly.less",
"keywords": [
"flatly",
"bootstrap",
"twitter bootstrap",
"bootswatch",
"less",
"css",
"flat",
"flat ui",
"theme"
] <-- missing comma
"ignore": [
"**/.*",
"node_modules",
"components"
],
"dependencies": {
"bootstrap-less": "2.3.2"
}
}
Your best bet is to redo the tag

Related

invalid composer.json metadata packagist

When I push new tag to my package to update my composer plugin it returns this error:
Update of failed, invalid composer.json metadata
[Composer\Repository\InvalidRepositoryException] Some branches
contained invalid data and were discarded, it is advised to review the
log and fix any issues present in branches
Here is my composer.json file:
{
"name": "package/name",
"description": "....",
"keywords": [
"...",
"...",
"..."
],
"homepage": "https://github.com/username/package-name",
"type": "composer-plugin",
"require": {
"php": "^7.4|^8.0",
"illuminate/support": "^7.0|^8.0|^9.0"
},
"require-dev": {
"composer/composer": "^2.0"
},
"license": "MIT",
"autoload": {
"psr-4": {
"Package\\Name\\": "src/"
}
},
"authors": [
{
"name": "My name",
"email": "my#email.com"
}
],
"minimum-stability": "dev"
}
And when I run composer validate I get ./composer.json is valid.
As you can see there is no domain name mention whatsoever but error is returning my domain name as invalid which says: must be an http/https URL
Any idea?
You need to read the error message in full and with peace of mind (unfortunately you were hiding it from the question by encoding it as image/png).
Don't look into one revision, instead search the history for it:
$ git log -p -S 'funding' main composer.json
It should get you started to learn about the revisions that are related to "funding" in composer.json within the main branch.

PhpStorm: what are php-cs-fixer files and how to ignore them

I keep getting "Multiple definitions exist for class..." warnings in PhpStorm, and upon inspection, I see these a bunch of these huge php-cs-fixer files (100K+ lines) with the comment "This file is part of PHP CS Fixer.".
I found that there are multiple copies of several other files named phploc, composer, php-scoper, etc., under vendor/library_name/tools/ in various libraries for some reason. They are all huge compiled files that PhpStorm detects.
I tried ignoring these files in PhpStorm one by one, and once re-indexing finishes, these files disappear, leading me to believe they're IDE-generated files. However, it makes no sense the IDE would generate them and in turn include them hinting code.
composer.json
{
"name": "magento/project-community-edition",
"description": "eCommerce Platform for Growth (Community Edition)",
"type": "project",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"config": {
"preferred-install": "dist",
"sort-packages": true
},
"require": {
"magento/composer-root-update-plugin": "~1.0",
"magento/product-community-edition": "2.4.1"
},
"require-dev": {
"allure-framework/allure-phpunit": "~1.2.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"friendsofphp/php-cs-fixer": "~2.16.0",
"lusitanian/oauth": "~0.8.10",
"magento/magento-coding-standard": "*",
"magento/magento2-functional-testing-framework": "^3.0",
"pdepend/pdepend": "~2.7.1",
"phpcompatibility/php-compatibility": "^9.3",
"phpmd/phpmd": "^2.8.0",
"phpstan/phpstan": ">=0.12.3 <=0.12.23",
"phpunit/phpunit": "^9",
"sebastian/phpcpd": "~5.0.0",
"squizlabs/php_codesniffer": "~3.5.4"
},
"conflict": {
"gene/bluefoot": "*"
},
"autoload": {
"psr-4": {
"Magento\\Framework\\": "lib/internal/Magento/Framework/",
"Magento\\Setup\\": "setup/src/Magento/Setup/",
"Magento\\": "app/code/Magento/",
"Zend\\Mvc\\Controller\\": "setup/src/Zend/Mvc/Controller/"
},
"psr-0": {
"": [
"app/code/",
"generated/code/"
]
},
"files": [
"app/etc/NonComposerComponentRegistration.php",
"app/helper.php"
],
"exclude-from-classmap": [
"**/dev/**",
"**/update/**",
"**/Test/**"
]
},
"autoload-dev": {
"psr-4": {
"Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
"Magento\\Tools\\": "dev/tools/Magento/Tools/",
"Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
"Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
"Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/",
"Magento\\PhpStan\\": "dev/tests/static/framework/Magento/PhpStan/"
}
},
"version": "2.4.0",
"minimum-stability": "stable",
"repositories": [
{
"type": "composer",
"url": "https://repo.magento.com/"
}
],
"extra": {
"magento-force": "override"
}
}
PhpStorm ignored files (adding php-cs-fixer and phploc here somehow removed all/multiple copies from the vendor directories):
These files are in your vendor directory as you must have install your dependencies from sources, not distributions.
Let's use sebastian/code-unit as an example to see how it works:
the file obviously is in the repository: https://github.com/sebastianbergmann/code-unit/tree/1.0.8/tools
but excluded from being exported to distribution (the archive file you are actually downloading from GitHub when installing package): https://github.com/sebastianbergmann/code-unit/blob/1.0.8/.gitattributes#L6 - you can see that it's not present in file you download from https://github.com/sebastianbergmann/code-unit/releases/tag/1.0.8
So, you must have install your dependencies using composer install --prefer-source (or composer update --prefer-source as it's the other command with that option) and you want to use --prefer-dist or actually not using any of these flags as the latter is the default. You can find more information about it in official documentation: https://getcomposer.org/doc/03-cli.md#install-i
Remove your vendor directory and install dependencies once more without --prefer-source flag.
AFAIR there was also an issue when you did not have curl extension installed, then simply add this extension.

Babel with babel-preset-env seems to ignore browserslist config

I’m testing Babel with browserslist in an npm script.
Here is my current package.json, in which Babel is doing what I expect:
{
"name": "npm-scripts-igloo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"devserver": "live-server",
"watch-sass": "node-sass sass/style.scss css/style.css --output-style expanded --watch",
"compile-sass": "node-sass sass/style.scss css/style.compiled.css --output-style expanded",
"prefix-css": "postcss css/style.compiled.css --use autoprefixer -o css/style.prefix.css",
"compress-css": "node-sass css/style.prefix.css css/style.min.css --output-style compressed",
"build-css": "npm-run-all compile-sass prefix-css compress-css",
"babel": "babel app.js --watch -o js/app.compiled.js",
"start": "npm-run-all -p devserver watch-sass babel"
},
"browserslist": [
"last 5 versions"
],
"babel": {
"presets": [
[
"env",
{
"targets": {
"browsers": [
"cover 99.5%"
]
}
}
]
]
},
"author": "",
"license": "ISC",
"devDependencies": {
"#fortawesome/fontawesome-free": "^5.6.1",
"autoprefixer": "^9.4.7",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"live-server": "^1.2.1",
"node-sass": "^4.11.0",
"npm-run-all": "^4.1.5",
"postcss-cli": "^6.1.1"
}
}
I’m not using a .babelrc file or any other configuration of Babel.
I’ve tried to target Edge 16 using the browserslist key:
"browserslist": [
"Edge 16"
]
With this configuration, Babel should NOT convert const to var, but it does, as explained here:
Babel doesn’t change const since Edge 16 supports it
https://github.com/browserslist/browserslist-example
However, if I target Edge 16 using the babel key:
"babel": {
"presets": [
[
"env",
{
"targets": {
"browsers": [
"Edge 16"
]
}
}
]
]
}
then Babel correctly doesn’t change const to var since Edge 16 supports it.
I would prefer to use the browserslist key, as it’s the recommended practice
https://github.com/browserslist/browserslist
Also, I could then simply share this browserslist option with autoprefixer, which is how it’s supposed to work.
But, the problem is that Babel seems to ignore the browserslist key.
The same is true if I use a .browserslistrc file containing:
Edge 16
There is an asterisked note on this slide:
https://slides.com/ai/browserslist#/14
that reports:
Only Babel 7 supports config file
So, I tried updating Babel to v7:
npm install #babel/core -D
This produced the following in devDependencies:
"#babel/core": "^7.3.4"
Unfortunately, that didn’t seem to make any difference.
So, my questions are:
Why does the browserslist key not appear to be affecting Babel? Is there something wrong with my syntax?
Does it matter where in package.json the browserslist key appears? i.e. does key order matter?
A little bit late for the party but I was reading through the docs and found out this:
"By default #babel/preset-env will use browserslist config sources unless either the targets or ignoreBrowserslistConfig options are set."
source: here
So in your case you need to get rid of targets property otherwise it will take precedence and neither .browserlistrc nor browserslist property in package.json will take effect.
Hope it helps!
try to clean cache in node_modules/.cache/babel-loader
Its worked for me with babel#7.6.0 with following config in .babelrc fie
'#babel/preset-env', {
'useBuiltIns': 'usage',
'corejs': 3,
'targets': {
'browsers': ['chrome 74']
}
}
Found more info here.
An or combiner can use the keyword or as well as ,. last 1 version or > 1% is equal to last 1 version, > 1%.
and query combinations are also supported to perform an intersection of the previous query: last 1 version and > 1%.

my-app.html missing from bundled build folder

I have a situation where I am using polymer starter-kit template for my app. My polymer.json files looks like this:
{
"entrypoint": "index.html",
"shell": "src/my-app.html",
"fragments": [
],
"sourceGlobs": [
"src/**/*",
"images/**/*",
"bower.json"
],
"includeDependencies": [
"manifest.json",
"bower_components/webcomponentsjs/webcomponents-lite.min.js"
]
}
When I build using polymer-cli command - 'polymer build', the bundled folder seems to miss the shell file 'my-app.html'.
If I remove
"shell": "src/my-app.html",
from the polymer.json file, the my-app.html file gets created in the bundled/src folder as it should but then the index.html file goes missing.
I am using the polymer-starter-kit template and adding files to it. I can't figure out why my-app.html or index.html goes missing depending on how polymer.json is configured.
Can you please tell me what's going wrong here?
Thank you.
I had the same problem with you yesterday and I added "/" at front of urls in polymer.json.
{
"entrypoint": "index.html",
"shell": "/src/my-app.html",
"fragments": [
"/src/my-app.html",
"/src/my-home.html",
"/src/my-shop.html"
],
"sourceGlobs": [
"src/**",
"src/**/*",
"src/structure/**/*",
"images/**/*",
"bower.json"
],
"includeDependencies": [
"manifest.json",
"bower_components/webcomponentsjs/webcomponents-lite.min.js"
]
}
I only added "/" at shell & fragments part and it worked.
I hope this can help.
Cheers.

How to ignore the error of the typings folder?

I added mongoose and also its typings.
When I npm run watch, I got the error in my terminal:
ERROR in /my-project/typings/globals/mongoose/index.d.ts (5,28): error
TS2307: Cannot find module 'mongodb'.
ERROR in /my-project/typings/globals/mongoose/index.d.ts (2071,32):
error TS2304: Cannot find name 'MongoosePromise'.
I changed my tsconfig.json "exclude" part to
"exclude": [
"typings/main.d.ts",
"typings/main",
"typings/globals/mongoose/index.d.ts",
"node_modules"
],
"exclude": [
"typings/main.d.ts",
"typings/main",
"typings/globals/mongoose",
"node_modules"
],
"exclude": [
"typings/main.d.ts",
"typings/main",
"typings/globals",
"node_modules"
],
Neither of above works.
And if I change to
"exclude": [
"typings",
"node_modules"
],
It will give me MORE errors (several pages).
How to ignore the error in the typing folder? Thanks
You should be:
Make sure mongodb and node definitions installed:
typings install dt~node dt~mongodb --global
Use the promise library
mongoose.Promise = your_promise
If you're using the default mpromise, you should:
typings install dt~mongoose-promise --global
You can find out more at here
Hop this help!