Error on build JavaScript project Travis-CI - javascript

I have a project which I am building locally with Gulp.js. But when I push it to GitHub and Travis start building it. I get the following error:
module.js:338
throw err;
^
Error: Cannot find module 'gulp-concat'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/travis/build/thyagostall/freecell/gulpfile.js:4:11)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
The .travis.yml:
language: node_js
node_js:
- "0.12"
before_script:
- npm install -g gulp gulp-concat gulp-connect gulp-html-replace gulp-eslint
script: gulp
Also my gulpfile.js:
var gulp = require('gulp'),
connect = require('gulp-connect'),
concat = require('gulp-concat'),
htmlreplace = require('gulp-html-replace');
var distDir = './build/',
sourceDir = './src/';
gulp.task('webserver', function() {
connect.server({
root: distDir,
port: 2345,
livereload: true
});
gulp.watch('src/**/*.*', ['build', 'images', 'styles', 'vendor']);
});
gulp.task('images', function() {
gulp.src(sourceDir + '**/*.{jpg,png,gif}')
.pipe(gulp.dest(distDir));
});
gulp.task('styles', function() {
gulp.src(sourceDir + '**/*.css')
.pipe(gulp.dest(distDir));
});
gulp.task('build', function() {
gulp.src([sourceDir + '**/utility.js', sourceDir + '**/game_events.js', sourceDir + '**/memento.js', sourceDir + '**/*.js'])
.pipe(concat('main.js'))
.pipe(gulp.dest(distDir))
.pipe(connect.reload());
});
gulp.task('vendor', function() {
gulp.src(sourceDir + '**/*.html')
.pipe(htmlreplace({
'vendor': 'vendor.js',
'js': 'main.js'
}))
.pipe(gulp.dest(distDir));
});
gulp.task('lint', function() {
gulp.src(sourceDir + '**/*.js')
.pipe(eslint())
.pipe(eslint.format())
});
gulp.task('default', ['build', 'images', 'styles', 'vendor']);
Is there any obvious thing I am missing?

First, change your .travis.yml to this:
language: node_js
node_js:
- "0.12"
before_script:
- npm install -g gulp
script: gulp
You only need to install gulp globally because this provides the gulp commmand line tool. Per the official npm documentation:
There are two ways to install npm packages: locally or globally. You choose which kind of installation to use based on how you want to use the package.
If you want to use it as a command line tool, something like the grunt CLI, then you want to install it globally. On the other hand, if you want to depend on the package from your own module using something like Node's require, then you want to install locally.
Second, I did some sleuthing on your github account (linked from your StackOverflow profile) and found the project you're trying to build. Looking at the package.json I see that there is no gulp-concat among the devDependencies. This is probably due to typing:
npm install gulp-concat
instead of:
npm install gulp-concat --save-dev
Which would explain why you can build the project locally, but it fails on Travis-CI. Adding the gulp-concat to yourdevDependencies should resolve the issue.

Related

Can't open VS Code on Ubuntu

Since today, I can't open vs code on both App shortcut and Terminal.
When I try to run any command related to VS Code like code, code --version and etc. I get this error:
Loading "minimist" failed
Error: EIO: i/o error, read
at Object.readSync (fs.js:592:3)
at Object.p.internalModuleReadJSON (electron/js2c/asar_bundle.js:5:11493)
at Object.read (internal/modules/package_json_reader.js:21:52)
at readPackage (internal/modules/cjs/loader.js:253:36)
at resolveExports (internal/modules/cjs/loader.js:436:15)
at Function.Module._findPath (internal/modules/cjs/loader.js:479:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:921:27)
at Module._load (internal/modules/cjs/loader.js:779:27)
at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
at Module.require (internal/modules/cjs/loader.js:1006:19)
at require (internal/modules/cjs/helpers.js:88:18)
at r (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:5:101)
at e.load (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:4:1723)
at e.load (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:3:10695)
at d (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:5:10300)
at Object.errorback (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:5:10421)
at e.triggerErrorback (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:3:11059)
at /snap/code/83/usr/share/code/resources/app/out/vs/loader.js:3:10765
at e.load (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:4:1740)
at e.load (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:3:10695)
at d (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:5:10300)
at i._loadModule (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:5:10430)
at i._resolve (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:6:452)
at i.defineModule (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:5:6142)
at v (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:6:1702)
at g (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:4:2557)
at Object.<anonymous> (/snap/code/83/usr/share/code/resources/app/out/vs/code/node/cli.js:9:115415)
at Object.<anonymous> (/snap/code/83/usr/share/code/resources/app/out/vs/code/node/cli.js:12:18613)
at e._createAndEvalScript (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:4:2601)
at /snap/code/83/usr/share/code/resources/app/out/vs/loader.js:4:2240
at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3) {
errno: -5,
syscall: 'read',
code: 'EIO',
phase: 'loading',
moduleId: 'minimist',
neededBy: [ 'vs/platform/environment/node/argv' ]
}
Here are the modules that depend on it:
[ 'vs/platform/environment/node/argv' ]
Try to install the minimist npm package globally with
npm install -g minimist
Accidentally removed some packages. Solved via reinstalling VS Code.

node_modules error: missing module postcss, when is present in node_modules/.bin

I'm trying to run a package.json script (with yarn) however it seems to fail due to a missing module. However when checking node modules it seems the relevant module is there, so I'm not clear how to resolve the error.
~/P/j/tw-tutorial ❯❯❯ yarn build:css
yarn run v1.22.4
$ postcss src/css/tailwind.css -o src/css/main.css
internal/modules/cjs/loader.js:955
throw err;
^
Error: Cannot find module '../'
Require stack:
- /Users/yunti/Projects/js/tw-tutorial/node_modules/.bin/postcss
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:952:15)
at Function.Module._load (internal/modules/cjs/loader.js:835:27)
at Module.require (internal/modules/cjs/loader.js:1012:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/yunti/Projects/js/tw-tutorial/node_modules/.bin/postcss:3:1)
at Module._compile (internal/modules/cjs/loader.js:1123:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
at Module.load (internal/modules/cjs/loader.js:972:32)
at Function.Module._load (internal/modules/cjs/loader.js:872:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/yunti/Projects/js/tw-tutorial/node_modules/.bin/postcss' ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
~/P/j/tw-tutorial ❯❯❯ postcss src/css/tailwind.css -o src/css/main.css
fish: Unknown command: postcss
~/P/j/tw-tutorial ❯❯❯ npx postcss src/css/tailwind.css -o src/css/main.css
Cannot find module '../'
Require stack:
- /Users/yunti/Projects/js/tw-tutorial/node_modules/.bin/postcss
~/P/j/tw-tutorial ❯❯❯ ll ./node_modules/.bin | grep postcss
-rwxr-xr-x 1 yunti staff 36B 24 Apr 10:20 postcss
update looks like the error is coming from postcss (not because postcss can't be found) as
postcss.config.js
module.exports = {
plugins:[
require('tailwindcss'),
require('autoprefixer'),
process.env.NODE_ENV === 'production' && require('#fullhuman/postcss-purgecss')({
content: [
'.src/**/*.js',
'.src/**/*.jsx',
'./public/index.html',
],
defaultExtractor: content=> content.match(/[A-Za-z0-9-_:/]+/g) || []
})
],
};

GulpJS: Assertion Error when trying to automate all tasks to form CSS files from SASS files

I have a problem regarding my task automation. I am using gulpJS and my css used is gulp-sass. I tried to learn this from a youtube video I found online -> https://www.youtube.com/watch?v=LYbt50dhTko and my main problem is, I tried to automate my css so that I won't have a hard time compiling both my css and sass files but I always get an error that says:
assert.js:339
throw err;
^
AssertionError [ERR_ASSERTION]: Task function must be specified
at Gulp.set [as _setTask]
(C:\Users\Applicant\Documents\responsive_screen\node_modules\undertaker\lib\set-task.js:10:3)
at Gulp.task
(C:\Users\Applicant\Documents\responsive_screen\node_modules\undertaker\lib\task.js:13:8)
at Object.<anonymous> (C:\Users\Applicant\Documents\responsive_screen\gulpfile.js:22:6)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
This is my first time coding in gulp js and I really want to learn this one. I will post my source code below this paragraph:
var gulp = require('gulp');
var sass = require('gulp-sass');
var uglifycss = require('gulp-uglifycss');
var watch = require('gulp-watch');
gulp.task('css', function(){
gulp.src('./css/*.css')
.pipe(uglifycss({
"maxLineLen": 80,
"uglyComments" : true
}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('sass', function () {
return gulp.src('./sass/*.scss')
.pipe(sass.sync().on('error', sass.logError))
.pipe(gulp.dest('./css'));
});
gulp.task('run', ['sass', 'css']);
gulp.task('watch', function(){
gulp.watch('./sass/*.scss', ['sass']);
gulp.watch('./css/*.css', ['css']);
});
gulp.task('default', ['run', 'watch']);
Can someone share solutions or ideas to this problem? It would be very much appreciated!

Gulp AssertionError [ERR_ASSERTION]: , how to specify task function?

I am leaning Golang from gorestful.
I am trying to reproduce this project on my Ubuntu 18.04.
If I go for
gulp
from command line
assert.js:42
throw new errors.AssertionError({
^
AssertionError [ERR_ASSERTION]: Task function must be specified
at Gulp.set [as _setTask] (/home/milenko/node_modules/undertaker/lib/set-task.js:10:3)
at Gulp.task (/home/milenko/node_modules/undertaker/lib/task.js:13:8)
at Object.<anonymous> (/home/milenko/go/src/github.com/MilenkoM/gulpfile.js:10:6)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
How to solve this?
gulp -v
[19:51:51] CLI version 3.9.1
[19:51:51] Local version 4.0.0
My gulpfile.js
var gulp = require("gulp");
var shell = require('gulp-shell');
// This compiles new binary with source change
gulp.task("install-binary", shell.task([
'go install github.com/MilenkoM/romanserver'
]));
// Second argument tells install-binary is a deapendency for restart-supervisor
gulp.task("restart-supervisor", ["install-binary"], shell.task([
'supervisorctl restart myserver'
]))
gulp.task('watch', function() {
// Watch the source code for all changes
gulp.watch("*", ['install-binary', 'restart-supervisor']);
});
gulp.task('default', ['watch']);
My tree
~/go/src/github.com/MilenkoM$ tree .
.
├── gulpfile.js
├── romanNumerals
│ └── data.go
└── romanserver
└── main.go

I'm getting Cannot find module 'protractor-jasmine2-html-reporter'

i tried to generate reports by using "'protractor-jasmine2-html-reporter'", but i'm getting module not found exception with error code 5..i tried the somany solutions gathered from stack overflow, but it is not worked. can somebody please help me in this.
Config.js
var Jasmine2HtmlReporter=require('protractor-jasmine2-html-reporter');
exports.config = {
directConnect : true,
capabilities:{
'browserName':'chrome'
},
framework: 'jasmine2',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['ProtractorTest/PageObjectMain.js'],
jasmineNodeOpts:{
defaultTimeoutInterval : 30000
},
onPreapre:function(){
jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({
savePath:"./test-results/report"
}));
},
}
Error log
[14:54:53] E/configParser - Error code: 105
[14:54:53] E/configParser - Error message: failed loading configuration file ReportConfig.js
[14:54:53] E/configParser - Error: Cannot find module 'protractor-jasmine2-html-reporter'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (H:\workspace\Protractor_tutorials\ReportConfig.js:1:88)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
and my 'Package.Json' not have any details about the report files.. so if that is the problem, please help me to how to configure those in json file.
There are few things you have to make sure while using Protractor Reporters
1.in my case, in the time creating variable for reporter instead of directly passing Reporter name try to pass the full path of Reporter module.. may this will work
Eg :
var Jasmine2HtmlReporter=require('C:/......./npm-modules/protractor-jasmine2-html-reporter');
2.make sure you running the Correct Configuration file having .js extension.
Installing without save-devworked for me .
Installed globally
npm install -g protractor-jasmine2-html-reporter
Run below command to link protractor and jasmine2-html-reporter to aovid report not generating issue. Please see Girish Sortur's answer in How to create Protractor reports with Jasmine2
npm link protractor-jasmine2-html-reporter
Also add this import with path to exact node module to avoid the error in windows 10
var Jasmine2HtmlReporter = require('C:/Users/sam/AppData/Roaming/npm/node_modules/protractor-jasmine2-html-reporter');
Full conifg,js that worked for me in windows 10 as per below.
//protractor jasminreporterconfig.js
//Add this import with path to exact node module to avoid the error
var Jasmine2HtmlReporter = require('C:/Users/sam/AppData/Roaming/npm/node_modules/protractor-jasmine2-html-reporter');
exports.config = {
framework: 'jasmine',
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [ "--start-maximized" ]
}
},
onPrepare: function() {
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
takeScreenshots: true,// By default this is enabled Default is true
takeScreenshotsOnlyOnFailures: false, // Default is false (So screenshots are always generated)
cleanDestination: true, // if false, will not delete the reports or screenshots before each test run.Default is true
showPassed: true,//default is true This option, if false, will show only failures.
fileName: 'MyRepoDemo', //We can give a prefered file name .
savePath: 'myproreports',//Reports location it will automatically generated
screenshotsFolder: 'screenshotsloc' //Screenshot location it will create a folder inside myproreports
})
);
},
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['src/com/sam/scriptjs/nonangularstackscript.js']
}
It looks like You haven't installed protractor-jasmine2-html-reporter
Go to folder where packages are installed (node_modules folder) and run:
npm install protractor-jasmine2-html-reporter
Try to check where the node_modules directory is present by running npm audit and which npm commands. The main thing is path where node_modules is installed should be traced and the new module like npm install protractor-jasmine2-html-reporter can be installed in that path

Categories