Can't compile assets with Gulp - gulp

Every tutorial or doc I find says that I should do something like this:
var elixir = require('laravel-elixir');
elixir.config.assetsPath = 'themes/ei/assets/src';
elixir.config.publicPath = 'themes/ei/assets/'
elixir(function(mix) {
mix.sass('style.scss');
mix.scripts('main.js');
});
But when I run gulp from the command line I get:
AssertionError [ERR_ASSERTION]: Task function must be specified
at Gulp.set [as _setTask] (/home/andrew/Development/eiweb/node_modules/undertaker/lib/set-task.js:10:3)
at Gulp.task (/home/andrew/Development/eiweb/node_modules/undertaker/lib/task.js:13:8)
at Object.<anonymous> (/home/andrew/Development/eiweb/node_modules/laravel-elixir/dist/tasks/recipes/default.js:30:6)
at Module._compile (internal/modules/cjs/loader.js:816:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
at Module.load (internal/modules/cjs/loader.js:685:32)
at Function.Module._load (internal/modules/cjs/loader.js:620:12)
at Module.require (internal/modules/cjs/loader.js:723:19)
at require (internal/modules/cjs/helpers.js:14:16)
at requireDir (/home/andrew/Development/eiweb/node_modules/require-dir/index.js:123:33)
My package.json file includes:
"dependencies": {
"gulp": "^4.0.2",
"laravel-elixir": "^6.0.0-18"
}
...and I have gulp-cli installed global.
What am I missing?

This issue occurs because of version issue gulp 4 has different signature for the task and laravel-elixir uses old signature of gulp 3 so it will cause error.
Best case would be to move https://laravel-mix.com as its based on webpack so it support more functionalities. also laravel-mix syntax is similar so its plus point.
For laravel-mix create this pacjage package.json file in root. or user latest from [ https://github.com/laravel/laravel ] public repo.
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.18",
"bootstrap": "^4.1.0",
"cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^4.0.7",
"lodash": "^4.17.5",
"popper.js": "^1.12",
"resolve-url-loader": "^2.3.1",
"sass": "^1.15.2",
"sass-loader": "^7.1.0",
"vue": "^2.5.17",
"vue-template-compiler": "^2.6.10"
}
}
Create webpack.mix.js in your root
const mix = require('laravel-mix');
// change theme path according to your need.
const themePath = 'themes/rainlab-bonjour';
mix.options({
publicPath: themePath + '/assets/compiled/'
})
// change script name and path according to your need.
mix.js(themePath + '/assets/src/main.js', 'main.js')
.sass(themePath + '/assets/src/main.scss', 'main.css');
Commands [ you can use this command with yarn or npm (I am using yarn)], you can read more info here. [ https://laravel-mix.com/docs/4.0/workflow ]
yarn watch -> it will watch files and compile files then generate compiled out-put in publicPath directory. in our case files will be.
themes/rainlab-bonjour/assets/compiled/main.js
themes/rainlab-bonjour/assets/compiled/main.css
Now you can just include them in theme using 'assets/compiled/main.js'|theme OctoberCms filter.
if you have any doubts please comment.

Related

Error in WDIO Chai/ Cucumber testsuite after updating chromedriver: #wdio/runner: TypeError: hooks.map is not a function at Obj.executeHooksWithArgs

I'm working on Wdio-Chai-Cucumber based e2e-testsuite that ran fine untill I had to update the chromedriver.
This is my stack:
"devDependencies": {
"#types/chai": "^4.2.13",
"#types/cucumber": "^6.0.1",
"#types/node": "^14.11.8",
"#types/webdriverio": "^5.0.0",
"#wdio/cli": "6.6.2",
"#wdio/cucumber-framework": "^6.10.6",
"#wdio/local-runner": "6.6.2",
"#wdio/spec-reporter": "6.8.1",
"#wdio/sync": "6.10.4",
"chai": "^4.2.0",
"chromedriver": "90.0.1",
"cucumber": "^7.0.0-rc.0",
"cucumber-html-reporter": "5.2.0",
"del-cli": "^3.0.1",
"eslint": "^7.10.0",
"wdio-chromedriver-service": "^7.1.0",
"wdio-cucumber-parallel-execution": "^3.6.14",
"wdio-cucumberjs-json-reporter": "2.0.2",
"wdio-docker-service": "^3.1.2"
},
"dependencies": {
"ts-node": "^9.0.0",
"typescript": "^4.0.3"
},
After updating the projects chromedriver from v90 to v98 I get the following error when I run "yarn run test"
#wdio/runner: TypeError: hooks.map is not a function at Object.executeHooksWithArgs
There is a log-message indicating that both cucumber#6.0.5 and cucumber#7.0.0-rc.0 have moved to #cucumber/cucumber, so I tried
yarn remove cucumber
yarn remove #types/cucumber
yarn add -D #cucumber/cucumber
But I still get the same error message when trying to run the test, like nothing has changed. What am I doing wrong?

npm start: Manual browser refresh to reflect changes

I'm learning Node.js and in the introductory course, I had to set-up node and npm. Now according to the instructor, after typing "npm start" in the terminal and then making changes in the index.html file, the browser is supposed to automatically refresh the tab for the changes to take effect, but in my case every time I make a change I had to manually refresh Safari tab to see the changes.
Please note I'm using the same machine, i.e. there is no server and client side per se. Operating system is macOS Catalina 10.15.6.
Any possible fixes please?
Thanks
File Structure:
package.json file:
{
"name": "confusion",
"version": "1.0.0",
"description": "This is a website for Ristorante Con Fusion",
"main": "index.html",
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server"
},
"author": "Raffay",
"license": "ISC",
"devDependencies": {
"lite-server": "^2.5.4"
},
"dependencies": {
"bootstrap": "^4.5.0",
"jquery": "^3.5.1",
"nodemon": "^2.0.4",
"popper.js": "^1.16.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/RaffaySajjad/conFusion.git"
},
"keywords": [
"conFusion"
],
"bugs": {
"url": "https://github.com/RaffaySajjad/conFusion/issues"
},
"homepage": "https://github.com/RaffaySajjad/conFusion#readme"
}
Starting nodemon from terminal using command "nodemon" prints following error
raffaysajjad#192 ~ % cd /Users/raffaysajjad/Desktop/Full\ Stack\ Web\ Development\ \(React\ Specialization\)/Course\ 1\ \(Front-End\ WebUI\ Frameworks\ \&\ Tools\ -\ Bootstrap\ 4\)/Week\ 1/Exercise/conFusion
raffaysajjad#192 conFusion % nodemon
[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: html,json
[nodemon] starting `node index.html`
/Users/raffaysajjad/Desktop/Full Stack Web Development (React Specialization)/Course 1 (Front-End WebUI Frameworks & Tools - Bootstrap 4)/Week 1/Exercise/conFusion/index.html:1
<!DOCTYPE html>
^
SyntaxError: Unexpected token '<'
at wrapSafe (internal/modules/cjs/loader.js:1053:16)
at Module._compile (internal/modules/cjs/loader.js:1101:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
[nodemon] app crashed - waiting for file changes before starting...
this is done by using the npm package of nodemon,
How to Use
npm install -g nodemon
and in your package.json use this
"scripts": {
"start": "nodemon npm run lite"
},
more about nodemon learn here
Yeah.Try installing nodemon.
npm install nodemon
It is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.
To run your server :
nodemon [your node app]
Nodemon will not helo you to browser reload for that kind of things you jest try plugins like connect-livereload
There are so many packages are there for this.
https://www.npmjs.com/package/reload
https://www.browsersync.io/

using PKG with featherjs app

Has anyone ever tried using pkg with featherjs before? I'm having trouble getting it to work.
I get the following error when running my executable:
WARNING: No configurations found in configuration directory:/../project/config
WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.
pkg/prelude/bootstrap.js:1172
throw error;
^
TypeError: root path required
at Function.serveStatic [as static] (/snapshot/../project/node_modules/serve-static/index.js:40:11)
Not sure where to go from here if anyone has any guidance.
"bin": "src/index.js",
"scripts": {
"test": "npm run eslint && npm run mocha",
"dev": "./node_modules/nodemon/bin/nodemon.js src/",
"eslint": "eslint src/. test/. --config .eslintrc.json",
"mocha": "mocha test/ --recursive --exit",
"start": "node src/",
"pkg": "pkg . -t node9-macos-x64 --out-path pkg"
},
"pkg": {
"assets": [
"src/**/*",
"public/**/*",
"config/**/*",
"node_modules/config/**/*.*"
],
"scripts": [
"src/**/*.js",
"config/**/*.json"
]
},
The error is coming from node-config used by #feathersjs/configuration which trying to load config/default.json from the folder of the running application, not the the bundled package. You can either try building with the NODE_CONFIG environment variable set to the content of config/defualt.json or remove app.configure(configuration()) and app.set the configuration options your application needs, for example by requiring config/default.json (which should also work in theh packaged environment):
const config = require('../config/default.json');
Object.keys(config).forEach(key => {
app.set(key, config[key]);
});

at=error code=H10 desc="App crashed" method=GET path="/" Error Deploying React/Node to Heroku

I'm trying to deploy a React on Node project I was working on and am running into some issues and I'm not certain why. Below is some information pulled from the log:
2018-02-11T00:12:22.875338+00:00 app[web.1]: > dmdb#1.0.0 start /app
2018-02-11T00:12:22.875340+00:00 app[web.1]: > node server.js
2018-02-11T00:12:22.875341+00:00 app[web.1]:
2018-02-11T00:12:23.315310+00:00 heroku[web.1]: State changed from starting to crashed
2018-02-11T00:12:23.299113+00:00 heroku[web.1]: Process exited with status 1
2018-02-11T00:13:23.976931+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=dmdb1.herokuapp.com request_id=8d37e10b-6999-4a2f-82bb-f3e724bf1c4e fwd="108.14.98.161" dyno= connect= service= status=503 bytes= protocol=https
Based on what the log shows, it seems like there's an issue with the start script in my package.json file, but I'm not sure why since I've used a similar one for another project I've deployed successfully. I did some research on this and I believe my Server.js file is configured and the ports are set up properly, I removed devdependencies and confirmed it works locally but not deployed, and I've got my SECRET_KEY set up in the vars since this has auth set up. Below is how I have my ports set up, and what my package.json file looks like on the backend. If anybody could please provide some insight I'd greatly appreciate it. If there's any additional information I can provide please let me know and I'll do so ASAP.
Ports from Server.js:
//app listening on port 1337
const PORT = process.env.PORT || 1337;
app.listen(PORT, () => {
console.log(`LISTENING ON PORT ${PORT}`)
})
Updated Package.json from Backside:
{
"name": "dmdb",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js",
"dev": "nodemon server.js",
"debugger": "DEBUG=*:* nodemon server.js",
"prod": "NODE_ENV=production node server.js",
"deploy": "cd client && yarn build && cp -a ./build/ ../public/",
"heroku-postbuid" : "cross-env NODE_ENV=production WEBPACK_CONFIG=browser_prod,server_prod webpack --colors",
},
"engines": {
"node": "8.5.0",
"yarn": "1.3.2"
},
"author": "Dan Levenson",
"license": "MIT",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.2",
"cookie-parser": "^1.4.3",
"cors": "^2.8.4",
"dotenv": "^4.0.0",
"ejs": "^2.5.7",
"ejs-lint": "^0.3.0",
"express": "^4.16.2",
"express-session": "^1.15.6",
"isomorphic-fetch": "^2.2.1",
"method-override": "^2.3.10",
"morgan": "^1.9.0",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"path": "^0.12.7",
"pg-promise": "^7.0.3"
}
}
Thanks in advance!
Editing post to include Package.JSON from client:
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router-dom": "^4.2.2",
"react-scripts": "1.1.0",
"reactstrap": "^5.0.0-beta"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:3001"
}
Adding Build Log:
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=true
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 8.5.0
engines.npm (package.json): unspecified (use default)
engines.yarn (package.json): 1.3.2
Resolving node version 8.5.0...
Downloading and installing node 8.5.0...
Using default npm version: 5.3.0
Resolving yarn version 1.3.2...
Downloading and installing yarn (1.3.2)...
Installed yarn 1.3.2
-----> Restoring cache
Loading 2 from cacheDirectories (default):
- node_modules
- bower_components (not cached - skipping)
-----> Building dependencies
Installing node modules (yarn.lock)
yarn install v1.3.2
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.30s.
-----> Caching build
Clearing previous node cache
Saving 2 cacheDirectories (default):
- node_modules
- bower_components (nothing to cache)
-----> Build succeeded!
-----> Discovering process types
Procfile declares types -> web
-----> Compressing...
Done: 20.7M
-----> Launching...
Released v12
https://dmdb-1.herokuapp.com/ deployed to Heroku
Rebuilt app using NPM instead of Yarn and it deployed without issue and is running fine now. Thanks for the help!
THIS SOLUTION IS FOR GO .
When you deploy an app through heroku, it does not allow you to specify the port number.
In other words, you can not specify your web service's port number as 8000 or something else, heroku decides the port number in runtime.
so, you can not use the following code:
log.Fatal(http.ListenAndServe(":8000", router))
What you can do is, getting the runtime port of heroku.
In short, just use the following code:
log.Fatal(http.ListenAndServe(":" + os.Getenv("PORT"), router))

Gulp doesn't work on Ubuntu 16.04 [duplicate]

As shown in the screen shot below I am not able to run gulp to concat the JavaScript files. Its saying that gulp is not defined.
I have tried the following commands:
npm install -g gulp
npm install gulp
npm install gulp --save-dev
I have also set the environment variables as following:
C:\Users\<user>\AppData\Roaming\npm;C:\Python27;C:\Users\<user>\AppData\Roaming\npm\node_modules;C:\Users\<user>\AppData\Roaming\npm\node_modules\gulp;
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
//script paths
var jsFiles = 'scripts/*.js',
jsDest = 'dist/scripts';
gulp.task('scripts', function() {
return gulp.src(jsFiles)
.pipe(concat('scripts.js'))
.pipe(gulp.dest(jsDest));
});
you just need to install and require gulp locally, you probably only installed it globally
At the command line
cd <project-root> && npm install --save-dev gulp
In your gulpfile.js
var gulp = require('gulp');
this is a different dependency than the command line dependency (that you installed globally). More specifically, it is the same NPM package, but the command line program will execute code usually from a different entry point in the NPM package then what require('X') will return.
If we go to the package.json file in the Gulp project on Github, it will tell the whole story:
{
"name": "gulp",
"description": "The streaming build system",
"version": "3.9.1",
"homepage": "http://gulpjs.com",
"repository": "gulpjs/gulp",
"author": "Fractal <contact#wearefractal.com> (http://wearefractal.com/)",
"tags": [ ],
"files": [
// ...
],
"bin": {
"gulp": "./bin/gulp.js"
},
"man": "gulp.1",
"dependencies": {
// ...
},
"devDependencies": {
// ...
},
"scripts": {
"prepublish": "marked-man --name gulp docs/CLI.md > gulp.1",
"lint": "eslint . && jscs *.js bin/ lib/ test/",
"pretest": "npm run lint",
},
"engines": {
"node": ">= 0.9"
},
"license": "MIT"
}
so at the command line:
$ gulp default
will execute this:
"bin": {
"gulp": "./bin/gulp.js"
},
on the other hand, require('gulp') in your code will return the value of this:
https://github.com/gulpjs/gulp/blob/master/index.js
normally we see this in a package.json file as:
"main": "index.js"
but since this is the default, they just omitted it (which is dumb IMO, better to be explicit, but they aren't the first project I have seen take the lame shorthand route.).
Its occurs on Windows and usually one of the following fixes it:
If you didn't, run npm install gulp on the project folder, even if
you have gulp installed globally.
Normally, It isn't a problem on Windows, but it could be a issue with
the PATH. The package will try to get the PATH from the environment,
but you can override it by adding exec_args to your gulp settings.
For example, on Ubuntu:
"exec_args": {
"path": "/bin:/usr/bin:/usr/local/bin"
}
Hope It will be OK.
Source: https://github.com/NicoSantangelo/sublime-gulp/issues/12