Can't run my grunt task using grunt-bower-task plugin - javascript

I've the same configuration like this thread in my gruntfile.
bower: {
install: {
options: {
targetDir: './lib',
install: true,
cleanTargetDir: false,
cleanBowerDir: false,
bowerOptions: {}
}
}
}
But wen I run my grunt task it throw the following error:
Running "bower:install" (bower) task
Fatal error: No bower.json present
That's a little weird because I've my bower.json file inside of the defined directory(lib). Also if I run inside of it throw the same error
Any suggestion?

did you tried running bower install from command prompt? How did you generated your project scaffold? Bower.json , package.json and gruntfile.js should be in your root directory.
Here is the best way to generate project scaffold and running the application using grunt and bower.
http://yeoman.io/codelab/setup.html
I hope this will help you.

bower.json needs to be in the same directory as your package.json/gruntfile etc. not in the target directory.

Related

Vue "npm run build" Ignores vue.config.js File

I have a Webpack-templated Vue project, initiated through vue-cli.
I have created a simple 'vue.config.js' file stored in the root folder (where package.json is at) containing the following:
// vue.config.js
module.exports = {
productionSourceMap: false
}
Though when building the project using "npm run build" it ignores it.
I have tried different configurations to check if the problem is with the file or the setting, and the problem is with the file.
I am using webpack#3.12.0, vue#2.6.11, #vue/cli 4.2.3 and npm#6.9.0.
Make sure your build confiuration (in your case the webpack build configs) include your file.
Generally, you will have a source folder (often src) and the builder will build all the files in that dir only. Then you have your destination directory (often dist or build) where your build files will be stored.
Two solutions:
add your conf file to the build source.
move your vue.conf.js file into your source directory
For some reason, I did not manage to get vue.config.js to work.
Alternatively, I edited my webpack config, which as my build files mentioned was located at /config/index.js
Then, I proceeded to pass my build configurations to the build parameter which already appears on the file.
build: {
...
}
And it worked. I assume it may be because I used npm run dev instead of the vue-service-cli, so webpack did not go through the vue.config.js file.

Electron require node_modules in main process: Error: Cannot find module ‘linvodb3’

For a angular2/electron learning app I use LinvoDB for persistent data storage based on the angular2-electron-starter seed that comes with two package.json one in root/ one in root/electron. After successful packaging the app.exe throws this error:
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module 'linvodb3'
So far I tried:
installing linvodb3 in / and /electron (npm install linvodb3 --save)
installing linvodb3 with --build-from-source
using electron-rebuild in both directories
apm install
multiple deinstallations and
installations of various packages recommended at similar questions.
var LinvoDB = require('linvodb3'); in the according module and main.js
const LinvoDB = require('electron').remote.require('linvodb3');
var LinvoDB = require('linvodb3'); in index.html similar to the jQuery questions.
The only thing I read about and couldn't try was to set the NODE_PATH manually cause I couldn't find a file where it's specified.
As suggested by #JensHabegger the initial problem can be solved by copying the node_modules from the /electron subfolder to /dist, I do this by a script in the /package.json.
The deeper problem of the not found leveldown lib couldn't be fixed with electron-rebuilt but with a postinstall script in /electron/package.json:
"scripts": {
"start": "electron .",
"postinstall": "cd node_modules/leveldown && node-gyp rebuild --target=1.4.8 --arch=x64 --dist-url=https://atom.io/download/atom-shell"
},

Loading grunt tasks from a remote Gruntfile.js

In the root directory of a project, I'm trying to load Grunt tasks, and all the content of the file as well, from a remote Gruntfile.js, accessible through a network (web or internal network).
I've already tried several things (see below), first hosting the Gruntfile.js on a local Apache server for the tests.
Using the --gruntfile option
> /project/path> grunt --gruntfile=http://localhost/Gruntfile.js build
Reading "Gruntfile.js" Gruntfile...ERROR
Fatal error: Unable to find "/project/path/http://localhost/Gruntfile.js" Gruntfile.
Using the --base option
> /project/path> grunt --base=http://localhost/Gruntfile.js build
process.chdir(grunt.option('base') || path.dirname(gruntfile));
Error: ENOENT, no such file or directory
Creating a Gruntfile.js located at the root directory of my project, which contains only the following code :
module.exports = function (grunt) {
grunt.loadTasks( 'http://localhost/Gruntfile.js' );
};
The result was :
> /project/path> grunt build
>> Tasks directory "http://localhost/Gruntfile.js" not found.
Warning: Task "build" not found. Use --force to continue.
Aborted due to warnings.
Another try with the Gruntfile.js
module.exports = function (grunt) {
require( 'http://localhost/Gruntfile.js' )( grunt );
};
Gave me this :
> /project/path> grunt build
Loading "Gruntfile.js" tasks...ERROR
>> Error: Cannot find module 'http://localhost/Gruntfile.js'
Warning: Task "build" not found. Use --force to continue.
Aborted due to warnings.
Edit: It seems there is no way of loading tasks from a grunt file not located on the disk. I will find another solution.
I ran into the same problem and this is my solution. I hope it helps someone in the present/future:
Create a npm package to host the Gruntfile.js and upload it to a repository (I´am currently using Bitbucket) This is how my package.json looks like:
{
"name": "my-remote-gruntfile-package",
"private": true,
"version": "0.0.1"
}
Configure it in the package.json of your current project and install it using npm install or just run
npm install git+ssh://git#bitbucket.org:user/my-remote-gruntfile-package.git#0.0.1
Create a bash script (or windows bash equivalent) to cover the problem of changing Gruntfile.js location and setting current base path. This is to avoid passing --gruntfile and --base parameters on every execution (this step is not mandatory)
#!/bin/bash
grunt --base ./ --gruntfile ./node_modules/my-remote-gruntfile-package/GruntFile.js $1
Note: take care of relative paths used on your Gruntfile.js
Requiring a separate file should work, note that you shouldn't refer to it via localhost, but rather the location on disk, for example ./somedir/yourtask.js. Here's an example:
yourtask.js:
module.exports = {
// your task config goes here
};
Your Gruntfile.js:
module.exports = function(grunt) {
var externalFile = require('./somedir/yourtask.js');
grunt.initConfig({
// some random tasks go here
yourtask: externalFile
});
};
This should work but I'm not able to run it right now and you haven't posted what kind of info you have defined in your separate file. You can also have a function in there as well.

JSPM - jspm install gives error "Registry not found"

Recently i started playing with aurelia-framework and so far so good but when i edited config.js to add some of my files that are not installed via jspm things worked fine i was importing my scripts no errors but when i cloned to another machine and run jspm install it fails cause it does't like that i have other paths other than npm and github in my config.js
Configjs
paths: {
"*": "dist/*",
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*",
"lib:*": "lib/*",
"styles:*": "styles/*"
},
map: {
"app-styles": "styles:app-styles",
"uisearch": "lib:uisearch/uisearch#1.0.0",
"component": "lib:component/component",
"classie": "lib:classie/classie#2.0.0",
"material": "lib:material/material",
"ripples": "lib:ripples/ripples",
"bootstrap-select": "lib:bootstrap-select/bootstrap-select#1.7.2"
other deps...
}
Error Message
err Registry lib not found.
err Unable to load registry lib
warn Installation changes not saved.
Please help am new to this :)
Avoid making changes to the map section of your config.js by hand. Instead use the jspm command line interface to add packages. The jspm CLI will maintain your config.js for you. For example, to add classie to your project you would execute the following:
jspm install npm:desandro-classie
More information at jspm.io.
Note: you don't need to edit the config.js to enable importing javascript/css that is part of your project.
If I'm interpreting your original post correctly you have a lib folder containing a ripples subfolder which has a ripples.js file inside of it. You could access this "ripples" module like this:
import ripples from 'lib/ripples/ripples';
ripples.foo();
...

Grunt Watch not working with file base set to subdirectory

I'm having an issue where Grunt Watch is not working with my subdirectory using Grunt. Here's my directory setup:
/home
--/repos
--/common
--/node_modules
-- gruntfile.js
-- package.json
And I've set the base manually to the home directory in my gruntfile:
grunt.file.setBase('../../');
I'd like to keep my gruntfile located in this directory for working with other folks on my team and not use multiple gruntfiles.
Running 'grunt' works just fine. However, when I have Grunt Watch running, I get an error when I update my files:
Waiting...OK
>> File "repos/common/js/controllers/UserCtrl.js" changed.
grunt-cli: The grunt command line interface. (v0.1.13)
Fatal error: Unable to find local grunt.
Here is the watch portion of my gruntfile:
watch: {
// js
js: {
files: [
'js/*.js',
'js/controllers/*.js',
'js/services/*.js',
'js/lib/*.js',
'm/js/*.js',
'm/js/controllers/*.js',
'm/js/services/*.js',
'm/js/lib/*.js',
'repos/common/js/controllers/*.js',
'repos/common/js/services/*.js',
'repos/common/js/lib/*.js',
],
tasks: ['concat']
},
// css
css: {
files: [
'repos/common/less/*.less',
'm/less/*.less',
'css/*.css',
'repos/common/css/lib/*.css',
],
tasks: ['newer:less', 'newer:cssmin', 'newer:concat_css']
}
}
What on earth am I not getting here? Any help would be super appreciated!
You missed installing the grunt module
The grunt-cli is a different module to the actual grunt. I think you should install grunt (that is what is meant with the local error message) at the local directory or above where your gruntfile.js is located.

Categories

Resources