When building my project using Grunt and bower, Foundation seems to be causing an error. You can see it downloading packages, etc, then it quits with:
Fatal error: Unable to find suitable version for jquery
Here's my bower.json:
{
"name": "MyProject",
"version": "1",
"dependencies": {
"cytoscape": "2.2.7",
"datatables": "1.9.4",
"font-awesome": "4.0.3",
"foundation": "5.2.2",
"jquery-legacy": "jquery#1.11.0",
"kineticjs": "5.1.0",
"nouislider": "6.2.0",
"rem-unit-polyfill": "1.2.4",
"respond": ">=1.4.2"
}
}
I've tried removing each dependency from the bower.json above, one by one, and re-run my grunt file (which includes a trigger for bower install) each time. I get that error until I remove the Foundation line - then everything works ok (well, until Grunt looks for foundation files).
I've looked in Foundation's bower.json and its dependencies, but nothing "seems" amiss.
I attempted to add a resolution to my bower.json:
...,
"resolutions": {
"jquery": "1.11.0"
}
}
But that didn't help. (though I may be using that incorrectly?)
If I try bower install direct from the command line I get this:
> Unable to find a suitable version for jquery, please choose one:
> 1) jquery#~1.8.0 which resolved to 1.8.3+1 and has datatables#1.9.4 as dependants
> 2) jquery#>= 2.1.0 which resolved to 2.1.1 and has foundation#5.2.2 as dependants
> 3) jquery#>=1.2 which resolved to 2.1.1 and has jquery.cookie#1.4.1 as dependants
> 4) jquery#>= 1.7.0 which resolved to 2.1.1 and has nouislider#6.2.0 as dependants
>
> Prefix the choice with ! to persist it to bower.json
>
> [?] Answer:
I can pick a version there, and it seems to work. But I need this to work within the build script.
Try changing jQuery to be:
"jquery": "~1.11.0"
EDIT
According to Foundation's bower.json, it states that it requires jQuery >= 2.1
{
"name": "foundation",
"version": "5.2.2",
"main": [
"css/foundation.css",
"js/foundation.js"
],
"dependencies": {
"jquery": ">= 2.1.0",
"modernizr": ">= 2.7.2",
"fastclick": ">=0.6.11",
"jquery.cookie": "~1.4.0",
"jquery-placeholder": "~2.0.7"
},
"devDependencies": {
"jquery.autocomplete": "devbridge/jQuery-Autocomplete#1.2.9",
"lodash": "~2.4.1"
},
"private": true
}
There is a conflict between the 2 version then. Did you change that?
Related
I have a Nextjs app using jest and react-testing-library for the test, I add the .eslintrc file with npx .eslintrc --init command to my project.
whenever I lint my project, I get the following error:
.eslintrc.js:
module.exports = {
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:#typescript-eslint/recommended",
"plugin:#typescript-eslint/recommended-requiring-type-checking",
"next",
"next/core-web-vitals"
],
"parser": "#typescript-eslint/parser",
"parserOptions": {
"project":"./tsconfig.json",
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
}
};
and error:
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
Error: Failed to load config "next" to extend from.
Referenced from: D:\web\reactjs\react-testing\react-testing-app\.eslintrc.js
Resolved, after installing this package, the code will run without error:
npm i --save-dev eslint-config-next
For a misterious reason running npm audit fix --force changed my package.json from:
"eslint-config-next": "12.0.1"
to:
"eslint-config-next": "^0.2.4"
I had to change it manually and the error went away.
Since I've posted this question in several software forms and got no useful answer, I hope to get an answer here from you as my colleges.
If you program in WordPress, you might now translations files .po/.mo. I'm looking now for a plugin in IntelliJ / WebStorm that can generate .mo files and extend the .po files above each translation by the used places:
#: /includes/.......
msgid "Cheatin’ huh?"
msgstr "So geht das leider nicht.."
So does anyone knows if there is a plugin that can do this? It would be enough to not enter the usage each time manually because this annoys me so much. The generation would only be a nice to have.
Thanks a lot!
As of writing this answer there is still no plugin that does this seemlessly. However you can acheive automation using a GRUNT task.
Using Grunt requires you have a nodejs development environment configured
Create a package.json in your project root similar to
{
"name": "yourProject",
"majorVersion": "0",
"minorVersion": "0",
"incrementalVersion": "1",
"qualifier": "-alpha",
"version": "0.0.1-alpha",
"description": "My great idea",
"main": "GruntFile.js",
"directories": {
"test": "test"
},
"repository": {
"type": "git",
"url": "https://yourgitrepo.com/name/project.git"
},
"dependencies": {},
"devDependencies": {
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-clean": "^2.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-exec": "^3.0.0",
"grunt-pot": "^0.3.0",
"grunt-replace": "^2.0.2",
"load-grunt-tasks": "^5.1.0",
"npm-cli": "^0.1.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Your Name",
"license": "SEE LICENCE IN LICENCE.txt"
}
Once created navigate using a terminal and run
npm install
This creates a node environment.
Now create a GruntFile.js
See below for example.
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
prvPkg: grunt.file.readJSON('private.json'),
clean: {
standard: ['myproject/target',
],
},
makepot: {
target: {
options: {
cwd: 'myproject/target/generated/myproject',
include: ['.*'],
domainPath: 'languages/', // Where to save the POT file.
mainFile: 'myproject.php', // Main project file.
potFilename: 'myproject.pot', // Name of the POT file.
type: 'wp-plugin',
potHeaders: {
'report-msgid-bugs-to': 'https://www.myproject.com.au',
'plural-forms': 'nplurals=2; plural=n != 1;',
'last-translator': 'Author Name <author#myproject.com.au>',
'language-team': 'My Team <author#myproject.com.au>',
poedit:true,
'x-poedit-keywordslist': true,
'x-textdomain-support': 'yes'
}
}
}
},
});
// Default task(s).
grunt.registerTask('createMachineLanguage', '', function () {
let exec = require('child_process').execSync;
let options = {
cwd: 'myproject/target/generated/myproject/languages/',
encoding: 'utf8'
}
let result = exec("msginit --no-translator --input=myproject.pot --locale=en --output=myproject_en_AU.po",options);
result += exec("msgfmt myproject_en_AU.po -o myproject_en_AU.mo",options);
result += exec("rm myproject_en_AU.po",options);
grunt.log.writeln(result);
});
grunt.registerTask('default',['clean:standard','makepot','createMachineLanguage'] );
}
The critical components are the grunt-pot grunt plugin. Your terminal environment must have the GNU gettext intalled which provides the function
msginit and msgfmt. The grunt process executes these tasks automatically.
Please note my environment was Ubuntu so you can see I use an rm to remove the po file once it is converted to an mo file.
So using the GruntTask plugin you can create your language files automatically. Executing them from GruntTask.
I've set c_cpp_properties.json to be:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/Cellar/qt/5.13.2/include/QtCore"
],
"defines": [],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
it reports: include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/Users/.../.cpp).C/C++(1696)
cannot open source file "QtCore/qstring.h" (dependency of "QTime")```
The compiler is looking for "QtCore/qstring.h". Based on the include path you've already specified I guess that will be under...
"/usr/local/Cellar/qt/5.13.2/include"
So you need to add that to your list of include paths.
add
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
to your config file.
See Visual Studio Code on macOS + Qt + Intellisense
Im trying to test an old project, and when i run npm install, all i get is:
npm WARN package.json xx# No repository field.
npm WARN package.json xx# No license field.
My package.json file looks like this:
{
"name": "xx",
"version": "",
"dependencies": {},
"devDependencies": {
"connect-livereload": "~0.3.2",
"grunt": "~0.4.1",
"grunt-bg-shell": "~2.3.1",
"grunt-contrib-csslint": "^0.2.0",
"grunt-contrib-sass": "^0.8.1",
"grunt-contrib-uglify": "^0.6.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-newer": "^0.8.0",
"grunt-ngrok": "^0.2.2",
"load-grunt-tasks": "~0.2.1",
"time-grunt": "~0.2.7"
},
"engines": {
"node": ">=0.8.0"
}
}
I havent run this kind of install in a while and im afraid im forgetting something, any ideas as to what ?
EDIT: it turns out the folder copy i had of the project had already a node_modules folder with everything installed, reason why running npm install wasnt doing anything. Although i thought there would be some kind of warning or message saying all modules are installed already.
Getting the warning is not a concern. If you can see a structure of npm packages being installed after the warning, then it works fine. In case you want to avoid these warning, you can add respository and license fields to your package.json.
"repository": {
"type": "git",
"url": "git://github.com/user/repo.git"
},
"license": "ISC"
You are missing a bracket from the end
{
"name": "xx",
"version": "",
"dependencies": {},
"devDependencies": {
"connect-livereload": "~0.3.2",
"grunt": "~0.4.1",
"grunt-bg-shell": "~2.3.1",
"grunt-contrib-csslint": "^0.2.0",
"grunt-contrib-sass": "^0.8.1",
"grunt-contrib-uglify": "^0.6.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-newer": "^0.8.0",
"grunt-ngrok": "^0.2.2",
"load-grunt-tasks": "~0.2.1",
"time-grunt": "~0.2.7"
},
"engines": {
"node": ">=0.8.0"
}
}
I sugges you to use npm init then install the packages by the cli-tool
for eg:
save to devDepencies
npm install connect-livereload grunt grunt-bg-shell ... --save-dev
save to depencies
npm install express ... --save
read more at: https://docs.npmjs.com/cli/install
It turns out the folder copy i had of the project had already a node_modules folder with everything installed, reason why running npm install wasnt doing anything. Although i thought there would be some kind of warning or message saying all modules are installed already.
My goal is the be able to build my project to two separate build folders, each with its' own Grunt tasks.
I noticed the grunt-cli has the --gruntfile option which allows you to specify another Gruntfile to use. So far, I have a Gruntfile.js working perfectly (near stock from Yeoman). Also, I have another Gruntfile2.js sitting alongside.
Gruntfile.js
var yeomanConfig = {
app: 'app',
dist: '../www_browser'
};
Gruntfile2.js
var yeomanConfig = {
app: 'app',
dist: '../www'
};
grunt build is meant to run Gruntfile.js, and does so perfectly.
grunt build --gruntfile Gruntfile2.js is meant to run Gruntfile2.js, and does so with some hiccups. (supposed to build to ../www folder NOT ../www_browser folder)
The --gruntfile directive builds to the proper folder for almost every task except grunt-usemin and gunt-contrib-htmlmin. I know this because of this output to the console here:
Running "usemin:css" (usemin) task
Processing as CSS - ../www_browser/styles/22f60055.main.css
Running "concurrent:dist" (concurrent) task
Running "htmlmin:dist" (htmlmin) task
File ../www_browser/404.html created.
File ../www_browser/index.html created.
You'll notice the ../www_browser, here in console output. Every other task runs in the expected ../www folder.
Is this a usemin cache thing? Grunt cache thing? Or do some tasks simply run from the default Gruntfile.js regardless of the --gruntfile Gruntfile2.js directive?
I have given up on trying to do multiple targets from a single Gruntfile for now. There are too many dependencies in Yeoman's Gruntfile.js that don't yet support multiple build targets, and I spent 12 hours to no avail with that approach.
Version Info
$: grunt --version
grunt-cli v0.1.9
grunt v0.4.1
$: npm --version
1.2.25
$: yo --version
1.0.3
package.json
{
"name": "myapp",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-concat": "~0.1.3",
"grunt-contrib-coffee": "~0.6.5",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-compass": "~0.2.0",
"grunt-contrib-jshint": "~0.4.1",
"grunt-contrib-cssmin": "~0.6.0",
"grunt-contrib-connect": "~0.2.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-bower-requirejs": "~0.4.1",
"grunt-contrib-requirejs": "~0.4.0",
"grunt-contrib-imagemin": "~0.1.3",
"grunt-contrib-watch": "~0.4.0",
"grunt-rev": "~0.1.0",
"grunt-usemin": "~0.1.10",
"grunt-mocha": "~0.3.0",
"grunt-open": "~0.2.0",
"grunt-svgmin": "~0.1.0",
"grunt-concurrent": "~0.1.0",
"matchdep": "~0.1.1",
"connect-livereload": "~0.2.0"
},
"engines": {
"node": ">=0.8.0"
}
}
It looks like you're using an older version of grunt-concurrent, which doesn't seem to be passing the grunt flags through to the child-processes.
See here: https://github.com/sindresorhus/grunt-concurrent/blob/v0.1.0/tasks/concurrent.js#L11
On the current version of the plugin, the flags are passed, see here: https://github.com/sindresorhus/grunt-concurrent/blob/v0.3.1/tasks/concurrent.js#L22
So, I suggest updating your version of grunt-concurrent:
npm install grunt-concurrent#latest --save-dev