phantomjs-pdf not work - node.js

I'm using phantomjs-pdf in my sailsjs app. This code working fine in my local machine(ubuntu 14.0). but server machine(ubuntu 12.0) cause error, like below
internal/child_process.js:274
var err = this._handle.spawn(options);
^
TypeError: Bad argument
at TypeError (native)
at ChildProcess.spawn (internal/child_process.js:274:26)
at exports.spawn (child_process.js:339:9)
at Object.exports.execFile (child_process.js:141:15)
at /var/www/test/node_modules/phantomjs-pdf/lib/phantomjs-pdf.js:83:16
at /var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:721:13
at /var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:52:16
at /var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:269:32
at /var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:44:16
at /var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:718:17
at /var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:167:37
at async.series.paperFormat (/var/www/test/node_modules/phantomjs-pdf/lib/phantomjs-pdf.js:51:70)
at /var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:713:13
at Immediate.iterate [as _onImmediate] (/var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:262:13)
at processImmediate [as _immediateCallback] (timers.js:371:17)
This is my error. Any one tell me what is the problem. help me.

Uninstall all NPM packages and then reinstall NPM packages.

Related

How do devs maintain old projects?

A year ago I've made a project for a course: https://github.com/GeorgeFlorian/Finished_link_project
Now, I am trying to make it work on my machine, but I have no luck.
I've got npm 7.13.0 and node 16.1.0.
I've ran npm update in order to update all the depencies.
Steps
I've cloned the repo into a PC than runs Linux Mint 20.1
I've ran npm install
npm update
npm run build and npm run serve return the same error:
georgeflorian#georgeflorian-desktop:~/New Volume/VSCode Projects/Finished_link_project$ npm run build
> proiect-link#0.1.0 build
> vue-cli-service build
таз Building for production...
ERROR Failed to compile with 1 error 2:55:41 PM
Syntax Error: TypeError: Cannot read property 'parseComponent' of undefined
You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
ERROR Build failed with errors.
I have no idea how to trace the error: Syntax Error: TypeError: Cannot read property 'parseComponent' of undefined.
Also, the NodeJS server won't start:
georgeflorian#georgeflorian-desktop:~/New Volume/VSCode Projects/Finished_link_project/server$ node app.js
node:internal/fs/utils:343
throw err;
^
Error: ENOENT: no such file or directory, stat '/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/dist/favicon.ico'
at Object.statSync (node:fs:1527:3)
at resolveSync (/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/node_modules/serve-favicon/index.js:187:17)
at favicon (/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/node_modules/serve-favicon/index.js:61:12)
at Object.<anonymous> (/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/server/app.js:46:9)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47 {
errno: -2,
syscall: 'stat',
code: 'ENOENT',
path: '/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/dist/favicon.ico'
}
I believe that many dependencies are deprecated, but this begs two questions:
If it worked back then and it hasn't been touched since, why doesn't it work now ?
How can I fix all the deprecated dependencies if npm update did not fix them ?
Ultimately, I would like to learn how to approach this kind of situation. Thank you.

error: A hook (`userconfig`) failed to load

after npm install , getting error like, i have checked every config file and also installed lodash manually after but still not working
error: A hook (`userconfig`) failed to load!
error: Error: In Sails v1.x, `sails.config.globals._` must be either `false` or an object (typically the value of `require('lodash')`)
at Sails.exposeGlobals (D:\Node_Project\POS\trunk\node_modules\sails\lib\app\private\exposeGlobals.js:47:44)
at Sails.wrapper [as exposeGlobals] (D:\Node_Project\POS\trunk\node_modules\#sailshq\lodash\lib\index.js:3250:19)
at emitNone (events.js:91:20)
at Sails.emit (events.js:185:7)
at Sails.emitter.emit (D:\Node_Project\POS\trunk\node_modules\sails\lib\app\private\after.js:50:11)
at D:\Node_Project\POS\trunk\node_modules\sails\lib\app\private\loadHooks.js:111:15
at Hook.initialize (D:\Node_Project\POS\trunk\node_modules\sails\lib\hooks\index.js:154:14)
at Hook.wrapper [as initialize] (D:\Node_Project\POS\trunk\node_modules\#sailshq\lodash\lib\index.js:3250:19)
at D:\Node_Project\POS\trunk\node_modules\sails\lib\hooks\index.js:88:16
at D:\Node_Project\POS\trunk\node_modules\sails\node_modules\async\dist\async.js:486:20
First : Make sure you've installed dependencies with npm install
Second : Check that this app was built for a compatible version of Sails.

unable to start nodejs app- Error: npm.load() required

whenever I am starting my Node app it's giving following error.
Error: Failed to replace env in config: ${NPM_TOKEN}
at /usr/local/lib/node_modules/npm/lib/config/core.js:429:13
at String.replace (native)
at envReplace (/usr/local/lib/node_modules/npm/lib/config/core.js:424:12)
at parseField (/usr/local/lib/node_modules/npm/lib/config/core.js:400:7)
at /usr/local/lib/node_modules/npm/lib/config/core.js:338:17
at Array.forEach (native)
at Conf.add (/usr/local/lib/node_modules/npm/lib/config/core.js:337:23)
at ConfigChain.addString (/usr/local/lib/node_modules/npm/node_modules/config-chain/index.js:244:8)
at Conf.<anonymous> (/usr/local/lib/node_modules/npm/lib/config/core.js:325:10)
at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16
/usr/local/lib/node_modules/npm/lib/npm.js:29
throw new Error('npm.load() required')
^
Error: npm.load() required
at Object.npm.config.get (/usr/local/lib/node_modules/npm/lib/npm.js:29:11)
at exit (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:58:40)
at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:387:3)
at emitOne (events.js:77:13)
at process.emit (events.js:169:7)
at process._fatalException (node.js:224:26)
Plz provide any solution. I totally stucked with this.Due to this issue I am unable to start my app and complete my work.
Temporary remove file .npmrc with your ${NPM_TOKEN}
Switch to proper node version ( with node version manager you can run like nvm use 12 )
export your environment variable "export NPM_TOKEN=yourvalue"
move back your .npmrc file and try to run your project again!

SailsJs Invalid module error

After I installed lodash or async plug-ins,
Console shows those error messages when I launch sails.js.
but I don't know what cause those error messages.
I need to solve this problem. please anyone help me.
error: A hook (`userconfig`) failed to load!
error: Error: Invalid module:[object Object]
at /Users/johndo/github/sails/testProject/node_modules/sails/node_modules/sails-build-dictionary/index.js:83:15
at forOwn (/Users/johndo/github/sails/testProject/node_modules/lodash/dist/lodash.js:2105:15)
at Function.forEach (/Users/johndo/github/sails/testProject/node_modules/lodash/dist/lodash.js:3302:9)
at buildDictionary (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/sails-build-dictionary/index.js:74:4)
at Function.module.exports.aggregate (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/sails-build-dictionary/index.js:190:9)
at Array.loadOtherConfigFiles [as 0] (/Users/johndo/github/sails/testProject/node_modules/sails/lib/hooks/moduleloader/index.js:164:27)
at /Users/johndo/github/sails/testProject/node_modules/sails/node_modules/async/lib/async.js:459:38
at Array.forEach (native)
at _each (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/async/lib/async.js:32:24)
at Object.async.auto (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/async/lib/async.js:430:9) [Error: Invalid module:[object Object]]
error: Error: Invalid module:[object Object]
at /Users/johndo/github/sails/testProject/node_modules/sails/node_modules/sails-build-dictionary/index.js:83:15
at forOwn (/Users/johndo/github/sails/testProject/node_modules/lodash/dist/lodash.js:2105:15)
at Function.forEach (/Users/johndo/github/sails/testProject/node_modules/lodash/dist/lodash.js:3302:9)
at buildDictionary (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/sails-build-dictionary/index.js:74:4)
at Function.module.exports.aggregate (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/sails-build-dictionary/index.js:190:9)
at Array.loadOtherConfigFiles [as 0] (/Users/johndo/github/sails/testProject/node_modules/sails/lib/hooks/moduleloader/index.js:164:27)
at /Users/johndo/github/sails/testProject/node_modules/sails/node_modules/async/lib/async.js:459:38
at Array.forEach (native)
at _each (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/async/lib/async.js:32:24)
at Object.async.auto (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/async/lib/async.js:430:9) [Error: Invalid module:[object Object]]
It looks like it's experiencing an error while parsing your configuration files. Try rolling back your changes.
Also, lodash and async come as globals in sails, so you don't need to install them. Just go to config/globals and uncomment _(lodash). That might fix your problem, as maybe sails is having a conflict between its installed version and yours.

Node.js Jsdom returning [Error: socket hang up] code: 'ECONNRESET' }

Trying to use jsdom under nodejs and receiving this error:
[Error: socket hang up] code: 'ECONNRESET' }
Using NodeJs v0.8.20, Ubuntu 12.04
var jsdom = require("jsdom");
jsdom.env({
html: 'http://www.google.com',
scripts: ['http://code.jquery.com/jquery.js'],
done: function (errors, window) { console.log(errors); }
});
http://clock.co.uk/tech-blogs/preventing-http-raise-hangup-error-on-destroyed-socket-write-from-crashing-your-nodejs-server
basically there was a bug where socket hang up errors were suppressed, but in node 0.8.20 it is no longer suppressed. however, most modules don't listen for that error event yet.
so... downgrade your node.js version and wait until jsdom fixes it, or use domains. pretty sure the issue is with jsdom using an older version of request. or you can just not use the HTTP parts of JSDOM.
It means that the other side unexpectedly shut down the connection.
When I try to run your script, I get this:
/Users/isaacs/dev/js/x/node_modules/jsdom/lib/jsdom.js:178
features = JSON.parse(JSON.stringify(window.document.implementation._fea
^
TypeError: Cannot read property 'implementation' of undefined
at exports.env.exports.jsdom.env.processHTML (/Users/isaacs/dev/js/x/node_modules/jsdom/lib/jsdom.js:178:59)
at Request.exports.env.exports.jsdom.env [as _callback] (/Users/isaacs/dev/js/x/node_modules/jsdom/lib/jsdom.js:283:9)
at Request.init.self.callback (/Users/isaacs/dev/js/x/node_modules/jsdom/node_modules/request/main.js:127:22)
at Request.EventEmitter.emit (events.js:99:17)
at Request.<anonymous> (/Users/isaacs/dev/js/x/node_modules/jsdom/node_modules/request/main.js:767:16)
at Request.EventEmitter.emit (events.js:126:20)
at IncomingMessage.Request.start.self.req.self.httpModule.request.buffer (/Users/isaacs/dev/js/x/node_modules/jsdom/node_modules/request/main.js:729:14)
at IncomingMessage.EventEmitter.emit (events.js:126:20)
at IncomingMessage._emitEnd (http.js:366:10)
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)

Resources