Hi I need some help with my discord bot. I searched up the errors and tried to fix it, but it just doesn’t work. It could have been a coding error on my end. PLEASE HELP and Thanks!
Link for the GitHub repository:
https://github.com/Verggz/Electrolite
Edit: errors that keep occuring
Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
2022-01-23T15:14:15.475287+00:00 app[worker.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2022-01-23T15:14:15.476783+00:00 app[worker.1]: /app/main.ts:1
2022-01-23T15:14:15.476784+00:00 app[worker.1]: import express from 'express';
2022-01-23T15:14:15.476785+00:00 app[worker.1]: ^^^^^^
2022-01-23T15:14:15.476785+00:00 app[worker.1]:
2022-01-23T15:14:15.476785+00:00 app[worker.1]: SyntaxError: Cannot use import statement outside a module
2022-01-23T15:14:15.476786+00:00 app[worker.1]: at wrapSafe (internal/modules/cjs/loader.js:1001:16)
2022-01-23T15:14:15.476786+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1049:27)
2022-01-23T15:14:15.476786+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2022-01-23T15:14:15.476787+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:950:32)
2022-01-23T15:14:15.476787+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:790:12)
2022-01-23T15:14:15.476787+00:00 app[worker.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
2022-01-23T15:14:15.476788+00:00 app[worker.1]: at internal/main/run_main_module.js:17:47
package.json:
{
"name": "electrolite",
"version": "0.0.1",
"description": "literally just project scyll v2 but better",
"main": "./build/main.js",
"scripts": {
"start": "node --max-old-space-size=512 ./build/main.js && export NODE_ENV=production",
"dev": "tsc && node ./build/main.js",
"bot": "node ./build/bot/main.bot.js",
"botdev": "tsc && node ./build/bot/main.bot.js"
},
"keywords": [
"minecraft"
],
"author": "PenguinDetox",
"license": "ISC",
"dependencies": {
"#discordjs/builders": "^0.11.0",
"#discordjs/rest": "^0.2.0-canary.0",
"axios": "^0.24.0",
"discord-api-types": "^0.26.1",
"discord.js": "^13.5.0",
"express": "^4.17.2",
"fs-extra": "^10.0.0",
"hypixel-api-reborn": "^9.0.3",
"prismarine-nbt": "^2.0.0",
"set-interval-async": "^2.0.3"
},
"devDependencies": {
"#types/express": "^4.17.13",
"#types/fs-extra": "^9.0.13",
"#types/node": "^17.0.4",
"#types/set-interval-async": "^1.0.0"
}
}
Procfile:
worker: node main.ts
I'm not totally sure what you're trying to do here, but the main issue at the moment is that you're asking Heroku to run your TypeScript code, not the compiled JavaScript. This is being done via your Procfile:
worker: node main.ts
You have a completely different command in your package.json:
"start": "node --max-old-space-size=512 ./build/main.js && export NODE_ENV=production",
This is probably closer to what you want, but we can't just use it like this.
The && export NODE_ENV part is unlikely to do anything useful: it will wait until your code stops running, then export an environment variable, then exit. Let's remove it:
"start": "node --max-old-space-size=512 ./build/main.js",
Now the issue is that build/main.js doesn't exist. You need to tell Heroku to build it during deployment. Based on your dev script, I believe that just involves running tsc.
Let's add a build script to do that:
"build": "tsc",
"start": "node --max-old-space-size=512 ./build/main.js",
(I don't see typescript in your devDependencies, which means tsc might fail to run. Make sure to include all dependencies in your package.json.)
Okay, so your build script will now tell Heroku to build your application during deployment and your build/main.js should exist. Your start script has been updated.
Let's deal with your Procfile. Update it to match the new start script:
worker: node --max-old-space-size=512 ./build/main.js
Commit all those changes and redeploy.
Related
I am trying to clone an application, which is given in their document under canvas API section. They have given an option for sample walkthrough [https://developers.google.com/actions/interactivecanvas/sample-walkthrough]. I have followed every step but I am getting an error that my intents are not handled.
You can see the code at [github.com/actions-on-google/dialogflow-snowman-nodejs.git].
I have tried seeing all the intent handlers, Also, i have tried changing all the packages to the lastest one, as i have mentioned in the question.
I am using following packages:
{
"name": "snowman-canvas-sample-functions",
"description": "Snowman Actions on Google Interactive Canvas Sample Functions",
"license": "Apache-2.0",
"private": true,
"engines": {
"node": "8"
},
"dependencies": {
"actions-on-google": "preview",
"firebase-admin": "~5.13.1",
"firebase-functions": "^2.0.2"
},
"scripts": {
"lint": "./node_modules/.bin/eslint --fix \"**/*.js\"",
"start": "firebase serve --only functions",
"deploy": "firebase deploy --only functions",
"test": "npm run lint"
},
"devDependencies": {
"eslint": "^6.0.1",
"eslint-config-google": "^0.13.0"
}
}
i am getting "Dialogflow IntentHandler not found for intent: Welcome at Function" error in the welcome intent itself. Please assist me what should i try next.
You need to make sure your Dialogflow intent name and your Firebase Function intent handler name are the same.
From here, you'd need to implement a handler:
const { dialogflow } = require('actions-on-google')
const app = dialogflow()
app.intent('Welcome', conv => {
conv.ask('Welcome!')
})
In laravel 5.8 / axios "^0.18", "vue": "^2.5.17" app I use Maatwebsite\Excel to upload csv file
It works in case I run laravel control in GET request,
but I use axios for post requests and running request the file is not downloaded at all.
I run my request in JS code :
axios({
method: ( 'post' ),
url: this.$store.getters.apiUrl + '/personal/run-user-list-export-to-csv',
data: { user_id : user_id, user_list_id: user_list_id },
}).then((response) => {
this.showPopupMessage("User list export", "User list successfully exported !", 'success');
}).catch((error) => {
this.showPopupMessage("User list export", 'Error exporting user\'s list !', 'error');
});
with control :
public function run_user_list_export_to_csv() // http://127.0.0.1:8000/api/run-user-list-export-to-csv
{
$request= request();
...
$ret= \Excel::download(new exportSearchResults($user_list_id), 'file.csv'); // if write RETURN this line file is not downloaded anyway...
return response()->json( ['error_code' => 1, 'message' => '', 'ret' => $ret, HTTP_RESPONSE_INTERNAL_SERVER_ERROR ] );
} // public function storerun_user_list_export_to_csv(UserLisRequest $request)
I browser's responce I see output :
{"error_code":1,"message":"","ret":{"headers":{}},"0":500}
But file is not downloaded. How correctly?
Modified :
I tried to remake with sending headers in my control action, like :
public function run_user_list_export_to_csv()
{
$request= request();
...
$filename= $title.'.csv';
$download_path= $filename;
$ret= \Excel::download(new exportSearchResults($user_list_id), $download_path);
\Log::info($ret);
$headers = ['Content-Type: application/csv','Content-Disposition: attachment; filename={$filename}'];
return response($download_path, 200,$headers);
} // public function storerun_user_list_export_to_csv(UserLisRequest $request)
I see in log file output :
[2019-06-14 04:46:23] local.INFO: HTTP/1.0 200 OK
Cache-Control: public
Content-Disposition: attachment; filename="aaa Z3 iuy65 .csv"
Date: Fri, 14 Jun 2019 04:46:23 GMT
Last-Modified: Fri, 14 Jun 2019 04:46:23 GMT
But no file is downloaded.
Which is the right way ?
Modified 2 :
1) I generate csv file but failed to download it in browser's download method. This way seemed preferable to me.
But I can move generated csv file to some directory(say /home/user/ ) and to open it in client's csv app.
2) How can I with vue js to define name of current user and his download directory (bearing in mind that clients can have different OS)
Modified 3 :
I found this https://github.com/ynishi/vuecsv plugin and tried to install it.
$ npm install ynishi/vuecsv
> core-js#2.6.9 postinstall /mnt/_work_sdb8/wwwroot/lar/wiznext/msg-laravel-application/node_modules/core-js
> node scripts/postinstall || echo "ignore"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
> bootstrap-vue#1.5.1 postinstall /mnt/_work_sdb8/wwwroot/lar/wiznext/msg-laravel-application/node_modules/bootstrap-vue
> opencollective postinstall || exit 0
Thanks for installing bootstrap-vue
Please consider donating to our open collective
to help us maintain this package.
Number of contributors: 227
Number of backers: 31
Annual budget: $774
Current balance: $1,190
Donate: https://opencollective.com/bootstrap-vue/donate
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ vuecsv#0.0.10
added 44 packages from 32 contributors and audited 17038 packages in 87.476s
found 1 high severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
The output above was somewhat unuaual, but was it just advirtisement.
Next I run :
npm audit fix
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
up to date in 8.632s
fixed 0 of 1 vulnerability in 17038 scanned packages
1 vulnerability required manual review and could not be updated
After that package.json :
{
"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.0.0",
"cross-env": "^5.1",
"jquery": "^3.4.1",
"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"
},
"dependencies": {
"cors": "^2.8.5",
"remove": "^0.1.5",
"v-tooltip": "^2.0.2",
"vee-validate": "^2.2.5",
"vee-validate-laravel": "^1.1.0",
"vue-js-modal": "^1.3.31",
"vue-moment": "^4.0.0",
"vue-notification": "^1.3.16",
"vue-router": "^3.0.6",
"vue-select": "^3.1.0",
"vue-slider-component": "^3.0.31",
"vue2-filters": "^0.6.0",
"vuecsv": "github:ynishi/vuecsv",
"vuejs-paginate": "^2.1.0",
"vuex": "^3.1.0"
}
}
I tried to use this https://jsfiddle.net/ynishif/1ztu8x8q/ fiddle,
But I Got error referenced at my file :
app.js?dt=1560770053:2823 Uncaught ReferenceError: VueCSV is not defined
at Module../node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/Horizontal/personal/userLists/list.vue?
in /Horizontal/personal/userLists/list.vue:
<script>
...
import Vue from 'vue';
Vue.component("csv-download", VueCSV.CsvDownload)
I am very confused as VueCSV is not defined anywhere, but it works if mentioned fiddle.
What did I miss?
Modified 4 :
I tried to import vuecsv in my *.vue file and after installing of vuecsv.min.js I have
/node_modules/vuecsv/dist/vuecsv.min.js file
and in my vue file I tried to make like :
<script>
import {bus} from '../../../../app';
import appMixin from '../../../../appMixin';
//import
import VueCSV from '/vuecsv/dist/vuecsv.min.js'; // /node_modules/vuecsv/dist/vuecsv.min.js
Vue.use(VueCSV);
Vue.component("csv-download" , VueCSV.CsvDownload )
but in console I see error :
ERROR in ./resources/js/components/Horizontal/personal/userLists/list.vue?vue&type=script&lang=js& (./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/Horizontal/personal/userLists/list.vue?vue&type=script&lang=js&)
Module not found: Error: Can't resolve '/vuecsv/dist/vuecsv.min.js' in '/mnt/_work_sdb8/wwwroot/lar/wiznext/msg-laravel-application/resources/js/components/Horizontal/personal/userLists'
# ./resources/js/components/Horizontal/personal/userLists/list.vue?vue&type=script&lang=js& (./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/Horizontal/personal/userLists/list.vue?vue&type=script&lang=js&) 124:0-48 127:8-14 132:30-36
# ./resources/js/components/Horizontal/personal/userLists/list.vue?vue&type=script&lang=js&
# ./resources/js/components/Horizontal/personal/userLists/list.vue
# ./resources/js/routes.js
# ./resources/js/app.js
# multi ./resources/js/app.js ./resources/sass/Horizontal/app.scss ./resources/sass/Horizontal/style_lg.scss ./resources/sass/Horizontal/style_md.scss ./resources/sass/Horizontal/style_sm.scss ./resources/sass/Horizontal/style_xs_320.scss ./resources/sass/Horizontal/style_xs_480.scss ./resources/sass/Horizontal/style_xs_600.scss
If i modify import line as :
import VueCSV from 'vuecsv'; // /node_modules/vuecsv/dist/vuecsv.min.js
I see error in npm console :
This dependency was not found:
* Vue in ./node_modules/vuecsv/dist/vuecsv.min.js
To install it, you can run: npm install --save Vue
sure I have vue installed.
Which way is right?
Can it be that this plugin is not working at? Can you propose similar ?
To upload file with axios :
const config = {
headers: {
"content-type": "multipart/form-data",
"Access-Control-Allow-Origin": "*"
}
};
axios.post(ROOT+'/image/upload',data,config);
Your laravel route :
Route::post('/image/upload','API\ImageController#upload');
Your ImageController :
public function upload(Request $request)
{
$file = $request->file('image');
I upgraded my Elixir version from 3.0 to 5.0. The npm update command runs fine but when I try to run gulp --production it fails.
I have given the error below which I get.
My package.json file (which should be identical to the one at https://github.com/laravel/laravel/blob/master/package.json)
{
"private": true,
"scripts": {
"prod": "gulp --production",
"dev": "gulp watch"
},
"devDependencies": {
"gulp": "^3.9.1",
"laravel-elixir": "^5.0.0",
"bootstrap-sass": "^3.3.0"
}
}
When running gulp --production I get the below error
/home/vagrant/Code/laravel/node_modules/laravel- elixir/node_modules/gulp- cssnano/node_modules/cssnano/node_modules/postcss/lib/lazy-result.js:157
this.processing = new Promise(function (resolve, reject) {
^
ReferenceError: Promise is not defined
at LazyResult.async (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-cssnano/node_modules/cssnano/node_modules/postcss/lib/lazy-result.js:157:31)
at LazyResult.then (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-cssnano/node_modules/cssnano/node_modules/postcss/lib/lazy-result.js:79:21)
at Transform.stream._transform (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-cssnano/index.js:27:17)
at Transform._read (_stream_transform.js:179:10)
at Transform._write (_stream_transform.js:167:12)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at Transform.Writable.write (_stream_writable.js:183:11)
at write (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-concat/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
at flow (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-concat/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
You need to upgrade Node also.
You can read here how it can be updated upgraded: https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version
I have a cli app written in coffee-script. The cli app uses commander (https://github.com/tj/commander.js) to take arguments. I have three files in my bin dir:
mediatidy
mediatidy-config
mediatidy-media
If I run bin/mediatidy in the project folder in bash commander executes fine. If I type bin/mediatidy config or bin/mediatidy media in bash commander also executes fine and is waiting for an <action>.
The odd thing is I published the project to npm and get different results when installed globally. If I install the project via sudo npm mediatidy -g (I am using Mac OSX 10.10) I can see the following files in /usr/local/bin/:
mediatidy
mediatidy-config
mediatidy-media
If I run bin/mediatidy in the project folder in bash commander executes fine. If I type bin/mediatidy config or bin/mediatidy media in bash I get the following error:
mediatidy config
/usr/local/lib/node_modules/mediatidy/bin/mediatidy-config:3
program = require 'commander'
^^^^^^^^^^^
SyntaxError: Unexpected string
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
Looks like a coffeescript compilation error... wat.
If I run the same command but with the dash, bin/mediatidy-config, it works fine. I have another app that is private that works without having to use the dash that is globally installed. What am I missing here?
edit: added my package.json file:
package.json:
{
"preferGlobal": true,
"main": "index",
"name": "mediatidy",
"description": "Keep your media nice and tidy!",
"version": "0.1.1",
"repository": {
"type": "git",
"url": "git#github.com:tkdan235/mediatidy.git"
},
"engines": {
"node": ">=0.10.0"
},
"directories": {
"bin": "bin",
"lib": "lib"
},
"dependencies": {
"async": "^0.9.0",
"coffee-script": "^1.8.0",
"colors": "^0.6.2",
"commander": "^2.1.0",
"fs-extra": "^0.11.1",
"lodash": "^2.4.1",
"nconf": "^0.7.1",
"node-dir": "^0.1.6",
"node-ffprobe": "^1.2.2",
"prompt": "^0.2.14",
"sqlite3": "^2.2.7"
},
"coffeelintConfig": {
"max_line_length": {
"name": "max_line_length",
"value": 120,
"level": "error",
"limitComments": true
}
}
}
This actually appears to be a limitation of Commander.js. At first glance, it doesn't appear to call the scripts as shell scripts. Instead, it calls them with node which won't be compiling the CoffeeScript code. See https://github.com/tj/commander.js/blob/master/index.js#L447-L479 (line 469 in particular).
Update:
After some further digging, it looks like this WAS once supported and working. The way sub-commands were called was just their script name. Then this pull request broke it: https://github.com/tj/commander.js/pull/173. The last working version for this behavior was in 2.1.0. You could pin your version to 2.1.0 to get this behavior back.
I'm a bit stuck with my Jenkins setup on OSX Lion 10.7.3.
I'm using Grunt in my webapp to run Jasmine tests, build less, create cache manifest etc. Everything works on my laptop Lion 10.7.5, but on the server box grunt fails from time to time with the following error:
$ grunt less
module.js:340
throw err;
^
Error: Cannot find module ''
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at ChildProcess.<anonymous> (/usr/local/lib/node_modules/grunt-cli/bin/grunt:44:3)
at ChildProcess.EventEmitter.emit (events.js:99:17)
at Process._handle.onexit (child_process.js:678:10)
This is intermittent, it fails approximately once out of five runs and is not task specific. It fails with the same rate when running grunt manifest or grunt test.
Once thing I noticed is that when it works it takes a second or two until the task starts executing, but when it fails it fails immediately.
I tried to remove node_modules, npm cache clear, reinstalling grunt-cli. Nothing works.
Here's my package.json:
{
"name": "webapp",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "0.4.0rc7",
"grunt-contrib-copy": "0.4.0rc7",
"grunt-contrib-concat": "0.1.2rc6",
"grunt-contrib-coffee": "0.4.0rc7",
"grunt-contrib-uglify": "0.1.1rc6",
"grunt-contrib-compass": "0.1.1rc8",
"grunt-contrib-jshint": "0.1.1rc6",
"grunt-contrib-mincss": "0.4.0rc7",
"grunt-contrib-connect": "0.1.1rc6",
"grunt-contrib-clean": "0.4.0rc6",
"grunt-contrib-htmlmin": "0.1.1rc7",
"grunt-contrib-imagemin": "0.1.1rc8",
"grunt-contrib-livereload": "0.1.0rc8",
"grunt-contrib-jasmine": "~0.3.2",
"grunt-contrib-less": "0.5.0",
"grunt-manifest": "0.4.0",
"grunt-jslint": "0.2.5",
"grunt-bower-hooks": "~0.2.0",
"grunt-usemin": "~0.1.7",
"grunt-regarde": "~0.1.1",
"grunt-requirejs": "~0.3.1",
"grunt-mocha": "~0.2.2",
"grunt-open": "~0.1.0",
"matchdep": "~0.1.1"
},
"engines": {
"node": ">=0.8.0"
}
}
npm and node versions:
$ npm -version
1.2.11
$ node --version
v0.8.20
I have now stripped down both packages.json and Gruntile.js:
$ cat package.json
{
"name": "webapp",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "0.4.0rc7",
"grunt-manifest": "0.4.0",
"matchdep": "~0.1.1"
},
"engines": {
"node": ">=0.8.0"
}
}
$ cat Gruntfile.js
'use strict';
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
manifest: {
generate: {
options: {
basePath: 'app/',
exclude: ['js/lib/amp/com.vaultus.api.WebApiAggregated.cache.js', 'js/lib/amp/com.vaultus.api.DebugWebApiAggregated.cache.js'],
timestamp: true
},
src: [
'index-hybrid.html',
'*.xml',
'js/**/*.js',
'css/**/*.css',
'css/images/**/*',
'i18n/**/*.js',
'template/**/*.html'
],
dest: 'app/cache-manifest.mf'
}
}
});
grunt.registerTask('build', [
'manifest'
]);
grunt.registerTask('default', ['build']);
};
No luck :(
We were hitting this issue on our CI builds.
After a bit of digging it looks like this was a bug in grunt-cli 0.1.6 and has been fixed in 0.1.7 of grunt-cli.