SyntaxError: Unexpected identifier 'pipefail' - node.js

I am having this issue when I try to deploy NodeJS app (built with NextJS) using pm2. I follow the instruction described here.
My attempt to execute pm2 start command seemed working, as shown by the snippet below.
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐ │ id │ name │ mode │ ↺ │ status │ cpu │ memory │ ├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤ │ 0 │ experti │ fork │ 0 │ online │ 0% │ 25.7mb │ └────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
But when I run pm2 list, the previous execution turned out to be error.
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐ │ id │ name │ mode │ ↺ │ status │ cpu │ memory │ ├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤ │ 0 │ process │ fork │ 15 │ errored │ 0% │ 0b │ └────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
I checked the pm2 logs as described by this answer and it led me to this log:
`
SyntaxError: Unexpected identifier 'pipefail'
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1088:15)
at Module._compile (node:internal/modules/cjs/loader:1123:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Object.<anonymous> (/home/equitica/.npm/_npx/5f7878ce38f1eb13/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
/home/<username>/.asdf/plugins/nodejs/shims/npm:4
set -o pipefail
^^^^^^^^
`
So, I checked the file that specified by the log, and found this line (shown below):
#! /usr/bin/env bash
set -eu
set -o pipefail <-- this line is probably the problem
I have no idea what the line means, and have no clue to solve the problem.

I solved this issue by removing the /home/<username>/.asdf/plugins/nodejs/shims/npm file and then execute pm2 start npm --name <process> -- run start.

Related

the vue-awesome-swiper dependency was not found

I tried to use swiper plugin on my nuxtjs project. But I've got error on my command line when I running "yarn run dev":
`
yarn run dev
yarn run v1.22.19
$ nuxt
WARN sass-loader#13.1.0 is installed but ^10.1.1 is expected
╭───────────────────────────────────────╮
│ │
│ Nuxt # v2.15.8 │
│ │
│ ▸ Environment: development │
│ ▸ Rendering: server-side │
│ ▸ Target: server │
│ │
│ Listening: http://localhost:3000/ │
│ │
╰───────────────────────────────────────╯
i Preparing project for development
i Initial build may take a while
√ Builder initialized
√ Nuxt files generated
* Client █████████████████████████ building (39%) 245/251 modul
es 6 active
node_modules\setimmediate\setImmediate.js
× Server
Compiled with some errors in 9.04s
× Client
Compiled with some errors in 10.53s
× Server
Compiled with some errors in 9.04s
ERROR Failed to compile with 1 errors
This dependency was not found:
* vue-awesome-swiper/dist/ssr in ./plugins/swiper.js
To install it, you can run: npm install --save vue-awesome-swiper/dist/ssr
i Waiting for file changes
i Memory usage: 143 MB (RSS: 232 MB)
i Listening on: http://localhost:3000/
WARN Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\DumpStack.log.tmp'
`
vue-awesome-swiper does not detected while I've installed by "yarn add vue-awesome-swiper".
And I've followed this instruction on cmd:
npm install --save vue-awesome-swiper/dist/ssr
i Waiting for file changes
i Memory usage: 143 MB (RSS: 232 MB)
i Listening on: http://localhost:3000/
But still have issued on my code. Does anyone have same problems and had solution?

Why can't I add packages to flutter

I tried to add dependencies:
english_words: ^3.1.5 To my pupsec.yaml file, when I do and try the Flutter Pub Get command I get this error: Mathiass-MacBook-Pro:startuplabs_0 mathiassoderlund$ flutter pub get
Error on line 34, column 5 of pubspec.yaml: A dependency may only have one source.
╷
34 │ ┌ sdk: flutter
35 │ │
36 │ │ dependencies:
37 │ │ flutter:
38 │ │ sdk: flutter
39 │ │
40 │ │
41 │ │ english_words: ^3.1.5
42 │ │
43 │ │ # For information on the generic Dart part of this file, see the
44 │ │ # following page: https://dart.dev/tools/pub/pubspec
45 │ │
46 │ └ # The following section is specific to Flutter.
╵
Running "flutter pub get" in startuplabs_0...
pub get failed (65; ╵)
Mathiass-MacBook-Pro:startuplabs_0 mathiassoderlund$
Here is my pupspec.yaml file: Pupspec.yaml
You write it on the wrong place, Write it below cupertino_icons
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
english_words: ^3.1.5
Use proper indentation(spaces) in front of english_words.
The code should looks like this-
dependencies:
flutter:
sdk: flutter
english_words: ^3.1.5
Hope this will help you.

how event loop phases handles the requests?

Event loop has phases as:
┌───────────────────────┐
┌─>│ timers │
│ └──────────┬────────────┘
│ ┌──────────┴────────────┐
│ │ I/O callbacks │
│ └──────────┬────────────┘
│ ┌──────────┴────────────┐
│ │ idle, prepare │
│ └──────────┬────────────┘ ┌───────────────┐
│ ┌──────────┴────────────┐ │ incoming: │
│ │ poll │<─────┤ connections, │
│ └──────────┬────────────┘ │ data, etc. │
│ ┌──────────┴────────────┐ └───────────────┘
│ │ check │
│ └──────────┬────────────┘
│ ┌──────────┴────────────┐
└──┤ close callbacks │
└───────────────────────┘
how does it work? does it jump from one phase to another? if yes then when it jumps? or it just maintains the que and executes the one callback after the another? and what is next tick , does it mean that when entire que is completed and que is empty then the loop starts over again? is there any actual loop in event loop? and how does this poll phase works? what happens when a new request arrives?
node maintains the worker pool (which are actually c++ threads), and whenever a some I/O task or any other blocking task comes, it hands over that task to that worker thread which actually carries out system task as interacting with database and getting data and when worker thread completes its task than worker thread puts the callback handler in event que back, and node takes this callback and executes it . Is this correct?
what is nodejs binding(c++)?
how event loop works? does it run on main thread?

Knex:Error Pool2 - error: password authentication failed for user "username" (Not using UNIX account)

The problem occurs with the following command:
knex --knexfile config/db/knexfile.js migrate:latest
I get the following error:
Knex:warning - Pool2 - Error: Pool was destroyed
Knex:Error Pool2 - error: password authentication failed for user "dennis"
Knex:Error Pool2 - error: password authentication failed for user "dennis"
Error: Pool was destroyed
at Pool._destroyPool (/home/dennis/projects/amgen-sites/data-api/node_modules/pool2/lib/pool.js:560:20)
at Pool.<anonymous> (/home/dennis/projects/amgen-sites/data-api/node_modules/pool2/lib/pool.js:474:18)
at Pool.<anonymous> (/home/dennis/projects/amgen-sites/data-api/node_modules/pool2/lib/pool.js:517:17)
at tryCatcher (/home/dennis/projects/amgen-sites/data-api/node_modules/knex/node_modules/bluebird/js/release/util.js:16:23)
at Promise.errorAdapter [as _rejectionHandler0] (/home/dennis/projects/amgen-sites/data-api/node_modules/knex/node_modules/bluebird/js/release/nodeify.js:35:34)
at Promise._settlePromise (/home/dennis/projects/amgen-sites/data-api/node_modules/knex/node_modules/bluebird/js/release/promise.js:558:21)
at Promise._settlePromise0 (/home/dennis/projects/amgen-sites/data-api/node_modules/knex/node_modules/bluebird/js/release/promise.js:606:10)
at Promise._settlePromises (/home/dennis/projects/amgen-sites/data-api/node_modules/knex/node_modules/bluebird/js/release/promise.js:681:18)
at Async._drainQueue (/home/dennis/projects/amgen-sites/data-api/node_modules/knex/node_modules/bluebird/js/release/async.js:138:16)
at Async._drainQueues (/home/dennis/projects/amgen-sites/data-api/node_modules/knex/node_modules/bluebird/js/release/async.js:148:10)
at Immediate.Async.drainQueues (/home/dennis/projects/amgen-sites/data-api/node_modules/knex/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:570:20)
at tryOnImmediate (timers.js:550:5)
at processImmediate [as _immediateCallback] (timers.js:529:5)
It seems like it is not using my UNIX account and instead trying to authenticate using username/password.
I have tried the following solutions:
Update pg to the latest
Update knex to the latest
replace the method to trust from:
# IPv4 local connections: host all all 127.0.0.1/32 trust
replace the connection string from [db name] to [postgres://[db name]:
connection: {
database: 'postgres://data-api-dev',
user: '',
password: ''
},
How to I get it to use my UNIX account?
I am on Ubuntu 16.04 using Node v6.3.1.
Here are my installed packages:
├── bluebird#2.10.2
├── body-parser#1.15.2
├── bookshelf#0.10.0
├── chai#3.5.0
├── chai-as-promised#5.3.0
├── colors#1.1.2
├── convict#1.4.0
├── cors#2.7.1
├── express#4.14.0
├── gulp#4.0.0-alpha.2 (git://github.com/gulpjs/gulp.git#d8f5c90a0622d19ef1943a2a3d02dc50e3c853e7)
├── gulp-exit#0.0.2
├── gulp-mocha#2.2.0
├── gulp-nodemon#2.1.0
├── gulp-using#0.1.0
├── jsonwebtoken#5.7.0
├── knex#0.11.10
├── lodash#3.10.1
├── pg#6.1.0
├── request-promise#0.4.3
├── sinon#1.17.5
├── sinon-as-promised#4.0.2
├── sinon-chai#2.8.0
├── supertest#1.2.0
└── validator#4.9.0
Turns out that renaming the method from md5 to trust was the correct solution. I forgot to restart the postgresql service after making the changes, thus it did not work the first time.

Parsoid Server didn't parse pages

Hello:) Got some problems with install of VisualEditor. I have to install Parsoid server and run it. But when I trying to parse some page, I'm getting an error:
TypeError: Cannot read property 'length' of undefined
at peg$c379 (eval at <anonymous> (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:89:38), <anonymous>:1356:61)
at peg$parseeof (eval at <anonymous> (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:89:38), <anonymous>:14738:12)
at peg$parsetlb (eval at <anonymous> (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:89:38), <anonymous>:2007:12)
at peg$parsetoplevelblock (eval at <anonymous> (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:89:38), <anonymous>:1909:12)
at Object.parse (eval at <anonymous> (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:89:38), <anonymous>:17872:18)
at PegTokenizer.tokenizeAsync (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:206:24)
at PegTokenizer._processText (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:180:8)
at PegTokenizer.process (/opt/bitnami/apps/parsoid/lib/mediawiki.tokenizer.peg.js:119:7)
at ParserPipeline.process (/opt/bitnami/apps/parsoid/lib/mediawiki.parser.js:485:21)
at Object.Util.processContentInPipeline (/opt/bitnami/apps/parsoid/lib/mediawiki.Util.js:1112:12)
This is not the same error like this, coz my express and connect versions look fine:
├── alea#0.0.9
├── async#0.9.0
├─┬ bunyan#1.0.1
│ └─┬ mv#2.0.3
│ ├─┬ mkdirp#0.5.0
│ │ └── minimist#0.0.8
│ ├── ncp#0.6.0
│ └── rimraf#2.2.8
├─┬ chai#1.9.2
│ ├── assertion-error#1.0.0
│ └─┬ deep-eql#0.1.3
│ └── type-detect#0.1.1
├── colors#0.6.2
├── diff#1.0.8
├── domino#1.0.18
├── entities#1.1.1
├── es6-shim#0.16.0
├─┬ express#2.5.11
│ ├─┬ connect#1.9.2
│ │ └── formidable#1.0.15
│ ├── mime#1.2.4
│ ├── mkdirp#0.3.0
│ └── qs#0.4.2
.......
I`ve got: NodeJS(v0.10.33), npm(2.1.5) on Ubuntu 14.04.1 LTS
Any ideas?:)
UPDATE:
I just noticed, that I can add new pages with VisualEditor and edit em, also i can edit already existing pages, but if there are no templates. If these pages have templates then there is an error previously described.
There was a problem with version (I got MW 1.23.6 (latest stable)).
I have to update to MediaWiki 1.24 and reinstall VisualEditor (Parsoid already exists in MW >1.24) and then it works fine without errors. Upstart on Ubuntu working well too.

Resources