Cannot find module on start of new Nodejitsu deployment - node.js

I have a node application that runs locally and when deploying to Nodejitsu via jitsu deploy, the CLI reports a successful deployment. However, when actually logging in to look at the application via the web based interface and attempting to activate the snapshot, the start fails with the following error:-
err Wed, 05 Nov 2014 14:10:37 GMT
err Wed, 05 Nov 2014 14:10:37 GMT module.js:340
err Wed, 05 Nov 2014 14:10:37 GMT throw err;
err Wed, 05 Nov 2014 14:10:37 GMT Error: Cannot find module '/opt/run/snapshot/package/js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
err Wed, 05 Nov 2014 14:10:37 GMT ^
The trouble I am having, is the vagueness of the error. What is '/opt/run/snapshot/package/js'? Is there a way of getting more detail out of Nodejitsu so I can see what maybe causing the problem? Is this something anyone else has had?
I can return to this question with more information if requested.
Help, as always, appreciated.

I solved this. The problem was in my packages.json I had the following:-
"scripts": {
"start": "js server",
"postinstall": "bower install",
"test": "make test-cov"
},
js is of course not recognised by Nodejitsu on run. I found, by changing it to:-
"scripts": {
"start": "node server.js"
},
I had no problems.
A note to future Nodejitsu deployers, postinstall runs locally -- not on the server; therefore remove bower_components from your .gitignore if you need bower components on nodejitsu.
Hope this helps any adventurers who wander by.

Related

How can I start Docusaurus as a service on Linux (Ubuntu)

Hi guys I try to start Docusaurus V2 as a service on ubuntu headless. Currently I have a script in my Docusaurus folder as a temporarly solution. It works when I start it with ./start.sh:
/var/www/citro-docs-2/start.sh
#!/bin/bash
npm run serve
I tried to create a service like that:
/etc/systemd/system/docusaurus.service
[Unit]
Description=Docusaurus Service
[Service]
ExecStart=/var/www/citro-docs-2/start.sh
WorkingDirectory=/var/www/citro-docs-2
[Install]
WantedBy=multi-user.target
But when I start it with sudo systemctl start docusaurus.service and check the status I get these errors:
● docusaurus.service - Docusaurus Service
Loaded: loaded (/etc/systemd/system/docusaurus.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2021-08-25 11:53:20 UTC; 4s ago
Process: 3494 ExecStart=/var/www/citro-docs-2/start.sh (code=exited, status=1/FAILURE)
Main PID: 3494 (code=exited, status=1/FAILURE)
Aug 25 11:53:20 citro-docs2 start.sh[3521]: at require (node:internal/modules/cjs/helpers:94:18)
Aug 25 11:53:20 citro-docs2 start.sh[3521]: at Object.<anonymous> (/var/www/citro-docs-2/node_modules/#docusaurus/c>
Aug 25 11:53:20 citro-docs2 start.sh[3521]: at Module._compile (node:internal/modules/cjs/loader:1101:14)
Aug 25 11:53:20 citro-docs2 start.sh[3521]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153>
Aug 25 11:53:20 citro-docs2 start.sh[3521]: at Module.load (node:internal/modules/cjs/loader:981:32)
Aug 25 11:53:20 citro-docs2 start.sh[3521]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
Aug 25 11:53:20 citro-docs2 start.sh[3521]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/r>
Aug 25 11:53:20 citro-docs2 start.sh[3521]: at node:internal/main/run_main_module:17:47
Aug 25 11:53:20 citro-docs2 systemd[1]: docusaurus.service: Main process exited, code=exited, status=1/FAILURE
Aug 25 11:53:20 citro-docs2 systemd[1]: docusaurus.service: Failed with result 'exit-code'.
I found a solution where I can start the .js file directly: How do I run a node.js app as a background service? but I don't know if this is also possible for Docusaurus. At least I don't know which .js file I should start. It would be awesome if someone could help.
Yes, it is possible to run Docusaurus as a service on Ubuntu. It's important to mention that what you're trying to do here is quite normal for Node.js apps. After all, if you don't run your Node.js app as a service, then the service would stop running as soon as you close the shell you used to start the app.
However, it seems like most folks don't run Docusaurus on Ubuntu since it's "just a static site" and static sites don't really need a full blown server to run on. For example, you could leverage GitHub Pages to run your docs site.
That being said, Docusaurus is just a Node.js app. It's similar to all other Node.js apps, and you can certainly run it in Ubuntu if you wanted to.
Take a look at the docs on PM2.
The way I would start your app as a service is:
Install Node.js on your Ubuntu server (if it isn't already installed)
Install pm2 globally on your server via npm install -g pm2
Navigate to your app's directory and run npm install to install the dependencies of your app.
Now you can run pm2 start /var/www/citro-docs-2/start.sh --name myDocsSite
Your Docusaurus app should now be running. To stop it, you can run pm2 stop myDocsSite.

Lighthouse reporting is failing in Jenkins with below error

Fri, 28 May 2021 09:27:18 GMT ChromeLauncher Waiting for browser.............................................................................................
Fri, 28 May 2021 09:27:19 GMT ChromeLauncher Waiting for browser...............................................................................................
Fri, 28 May 2021 09:27:19 GMT ChromeLauncher Waiting for browser.................................................................................................
Fri, 28 May 2021 09:27:20 GMT ChromeLauncher Waiting for browser...................................................................................................
Fri, 28 May 2021 09:27:20 GMT ChromeLauncher Waiting for browser.....................................................................................................
Fri, 28 May 2021 09:27:21 GMT ChromeLauncher Waiting for browser.......................................................................................................
Fri, 28 May 2021 09:27:21 GMT ChromeLauncher:error connect ECONNREFUSED 127.0.0.1:36157
Fri, 28 May 2021 09:27:21 GMT ChromeLauncher:error Logging contents of /tmp/lighthouse.mOZ6RIf/chrome-err.log
Fri, 28 May 2021 09:27:21 GMT ChromeLauncher:error Fontconfig warning: "/etc/fonts/fonts.conf", line 86: unknown element "blank"
Inconsistency detected by ld.so: ../elf/dl-tls.c: 488: _dl_allocate_tls_init: Assertion `listp->slotinfo[cnt].gen <= GL(dl_tls_generation)' failed!
Unable to connect to Chrome
370/0: Lighthouse analysis FAILED for https://website.com/en/....
rm: no such file or directory: report/lighthouse/website/en....report.json
/var/lib/jenkins/workspace/project/node_modules/lighthouse-batch/index.js:219
const score = toScore(summary.detail.performance)
TypeError: Cannot read property 'performance' of undefined
at checkBudgets (/var/lib/jenkins/workspace/project/node_modules/lighthouse-batch/index.js:219:42)
at /var/lib/jenkins/workspace/project/node_modules/lighthouse-batch/index.js:67:20
at Array.map (<anonymous>)
at execute (/var/lib/jenkins/workspace/project/node_modules/lighthouse-batch/index.js:39:38)
at Object.<anonymous> (/var/lib/jenkins/workspace/project/node_modules/lighthouse-batch/run.js:28:1)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Lighthouse_Reports#1.0.0 lighthouse: `lighthouse-batch -f sites.txt -p --config-path=config.js -h --performance 75 --score 70 --no-report –chrome-flags='–headless','--no-sandbox'`
npm ERR! Exit status 1
I'm running this report for 900+ page urls.
As the logs tell, ChromeLauncher is refusing connection to Jenkins. You might want to check if Jenkins is allowed to access this running service.
This can also happen if your ChromeLauncher is not running in headless mode, or multiple instances of ChromeLauncher are running, and no available ports for it are left.
You can try adding the following to you ChromeLauncher launch configs. In fact, you should mention these.
chromeOptions = {
chromeFlags: ["--disable-gpu", "--headless", "--enable-logging"]
}
Find more details to this here.
As an alternative, you can consider running Lighthouse in a Docker instead, to isolate it from Jenkins. This way, you can scan your project, generate HTML reports and publish it back to Jenkins.
You can follow the approach mentioned here.

Apex Up - Error: Cannot find module 'debug'

The error persists after I CLI enter up stack delete and also when I CLI enter up in an alternative directory that I know worked previously. Error also persists if I revert inconsequential changes to a prior working state.
Changing the name field in the up.json file results in a successful deploy in the alternate directory! But something about deploying with the same alternate name from my problem directory causes the issue again.
npm i -S debug does not help.
Has anyone else experienced and resolved this problem somehow?
UPDATE: Getting closer. By commenting things in and out I've got the error
"Error: Cannot find module './src/resolvers'"
From line:
var resolvers_1 = require("./src/resolvers");
Changing to:
var resolvers_1 = require("./resolvers");
fixes the single import issue, but not the remaining...
I'd move the index.js file to the src directory and keep a flat file structure... but I have complex reasons I can't do that.
"apex logs" of issue:
Aug 31st 05:58:27pm INFO staging 88776d6 initializing
Aug 31st 05:58:27pm INFO staging 88776d6 starting app: PORT=33461 command=node dist/index.js
Aug 31st 05:58:27pm INFO staging 88776d6 started app
Aug 31st 05:58:27pm INFO staging 88776d6 waiting for app to listen on PORT
Aug 31st 05:58:28pm ERRO staging 88776d6 module.js:549
Aug 31st 05:58:28pm ERRO staging 88776d6 throw err;
Aug 31st 05:58:28pm ERRO staging 88776d6 ^
Aug 31st 05:58:28pm ERRO staging 88776d6
Aug 31st 05:58:28pm ERRO staging 88776d6 Error: Cannot find module 'debug'
Aug 31st 05:58:28pm ERRO staging 88776d6 at Function.Module._resolveFilename (module.js:547:15)
Aug 31st 05:58:28pm ERRO staging 88776d6 at Function.Module._load (module.js:474:25)
Aug 31st 05:58:28pm ERRO staging 88776d6 at Module.require (module.js:596:17)
Aug 31st 05:58:28pm ERRO staging 88776d6 at require (internal/module.js:11:18)
Aug 31st 05:58:28pm ERRO staging 88776d6 at Object. (/var/task/node_modules/finalhandler/index.js:14:13)
Aug 31st 05:58:28pm ERRO staging 88776d6 at Module._compile (module.js:652:30)
Aug 31st 05:58:28pm ERRO staging 88776d6 at Object.Module._extensions..js (module.js:663:10)
Aug 31st 05:58:28pm ERRO staging 88776d6 at Module.load (module.js:565:32)
Aug 31st 05:58:28pm ERRO staging 88776d6 at tryModuleLoad (module.js:505:12)
Aug 31st 05:58:28pm ERRO staging 88776d6 at Function.Module._load (module.js:497:3)
Aug 31st 05:58:42pm FATA staging 88776d6 error creating handler: waiting for http://127.0.0.1:33461 to be in listening state: timed out after 15s: name=clowdfuncserver type=server
Aug 31st 05:58:42pm INFO 2018-09-01T00:58:42.959Z 22adf73a-ad82-11e8-9c6c-79de5ffabc3f Error: read ECONNRESET
at _errnoException (util.js:1022:11)
at Pipe.onread (net.js:628:25)
Despite additional issues blocking me, this webpack configuration worked for me:
// webpack.config.js
module.exports = {
entry: "./src/index.ts",
module: {
rules: [
{
exclude: [/node_modules/],
test: /\.tsx?$/,
use: "ts-loader"
},
{
include: /node_modules/,
test: /\.mjs$/,
type: "javascript/auto"
}
]
},
node: false,
output: {
filename: "index.js",
path: path.join(__dirname, "dist")
},
resolve: {
extensions: [".tsx", ".ts", ".js", ".mjs"]
},
target: "node"
};

Angular Quickstart fails karma testing out of the box

The official Angular quickstart is not able to run karma tests after a clean install on Windows 10. I typed the following 4 commands and nothing else:
C:\projects\temp>git clone https://github.com/angular/quickstart.git
C:\projects\temp>cd C:\projects\temp\quickstart
C:\projects\temp\quickstart>npm install
...install logs omitted for brevity
C:\projects\temp\quickstart>npm start
...app launched successfully, but logs omitted for brevity
C:\projects\temp\quickstart>npm test
...Error shown in complete logs below
The full error message resulting after the final command is as follows:
C:\projects\temp\quickstart>npm test
> angular-quickstart#1.0.0 pretest C:\projects\temp\quickstart
> npm run build
> angular-quickstart#1.0.0 build C:\projects\temp\quickstart
> tsc -p src/
> angular-quickstart#1.0.0 test C:\projects\temp\quickstart
> concurrently "npm run build:watch" "karma start karma.conf.js"
[0]
[0] > angular-quickstart#1.0.0 build:watch C:\projects\temp\quickstart
[0] > tsc -p src/ -w
[0]
[1] 01 06 2017 14:33:49.385:WARN [watcher]: Pattern "C:/projects/temp/quickstart/testing/**/*.js" does not match any file.
[1] 01 06 2017 14:33:49.406:WARN [watcher]: Pattern "C:/projects/temp/quickstart/testing/**/*.ts" does not match any file.
[1] 01 06 2017 14:33:49.407:WARN [watcher]: Pattern "C:/projects/temp/quickstart/testing/**/*.js.map" does not match any file.
[1] 01 06 2017 14:33:49.891:WARN [karma]: No captured browser, open http://localhost:9876/
[1] 01 06 2017 14:33:49.906:WARN [karma]: Port 9876 in use
[1] 01 06 2017 14:33:49.908:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9877/
[1] 01 06 2017 14:33:49.908:INFO [launcher]: Launching browser Chrome with unlimited concurrency
[1] 01 06 2017 14:33:49.958:INFO [launcher]: Starting browser Chrome
[1] 01 06 2017 14:33:51.821:INFO [watcher]: Changed file "C:/projects/temp/quickstart/src/app/app.component.js".
[1] 01 06 2017 14:33:51.843:INFO [watcher]: Changed file "C:/projects/temp/quickstart/src/app/app.component.spec.js".
[1] 01 06 2017 14:33:51.850:INFO [watcher]: Changed file "C:/projects/temp/quickstart/src/app/app.module.js".
[0] 2:33:51 PM - Compilation complete. Watching for file changes.
[1] 01 06 2017 14:33:51.873:INFO [watcher]: Changed file "C:/projects/temp/quickstart/src/main.js".
[1] 01 06 2017 14:33:51.965:INFO [Chrome 58.0.3029 (Windows 10 0.0.0)]: Connected on socket pXysNFDP8RC3agm8AAAA with id 9156960
[1] 01 06 2017 14:33:52.077:INFO [karma]: Delaying execution, these browsers are not ready: Chrome 58.0.3029 (Windows 10 0.0.0)
What needs to change in order for npm test to succeed out of the box on Windows 10?
The Angular quickstart project has largely been superseded by the Angular CLI. I would suggest using the CLI it for any new projects as it not only gives you an initial framework for your application, but it will also generate the additional boilerplate needed as you extend your application.
Before installing Angular CLi, ensure you have an up to date version of Node (6.9.0 or higher) and NPM (3 or higher). Also there may be other prerequisites not listed in the documentation, to install on an Android system I found it also needed Python 2.7 and g++ installed.
Install with:
npm install -g #angular/cli
To create a new project:
ng new PROJECT-NAME
cd PROJECT-NAME
ng serve
ng new will take some time to complete as in addition to building the project structure it also does the npm install.
Run unit tests with ng test and end-to-end tests with ng e2e.
Both ng test and ng serve will run continuously watching for changes and rebuilding the affected code. You can even leave both running in separate windows if you wish.
ng generate BLUEPRINT will generate new code, blueprints include module, component, service, class, directive, enum, guard, interface, pipe
Other useful commands:. You may want to experiment with this a bit before you write a real app: by default each component or service goes into its own subdirectory and is added to the top level app module, but you can explicitly create modules to provide additional structure if you wish.
ng build: builds your application into the output path.
ng doc KEYWORD: opens angular documentation for that keyword.
ng eject: ejects the app and outputs webpack configuration
ng lint: lints the project
ng xi18n: extracts i18n messages from the project.
This is not answer, just give more case to find out root cause.
I followed steps which you described and got this:
D:\Project\temp\quickstart>npm test
> angular-quickstart#1.0.0 pretest D:\Project\temp\quickstart
> npm run build
> angular-quickstart#1.0.0 build D:\Project\temp\quickstart
> tsc -p src/
> angular-quickstart#1.0.0 test D:\Project\temp\quickstart
> concurrently "npm run build:watch" "karma start karma.conf.js"
[0]
[0] > angular-quickstart#1.0.0 build:watch D:\Project\temp\quickstart
[0] > tsc -p src/ -w
[0]
[1] 02 06 2017 22:34:04.733:WARN [watcher]: Pattern
"D:/Project/temp/quickstart/testing/**/*.js" does not match any file.
[1] 02 06 2017 22:34:04.746:WARN [watcher]: Pattern
"D:/Project/temp/quickstart/testing/**/*.ts" does not match any file.
[1] 02 06 2017 22:34:04.747:WARN [watcher]: Pattern
"D:/Project/temp/quickstart/testing/**/*.js.map" does not match any file.
[1] 02 06 2017 22:34:05.103:WARN [karma]: No captured browser, open
http://localhost:9876/
[1] 02 06 2017 22:34:05.120:INFO [karma]: Karma v1.7.0 server started at
http://0.0.0.0:9876/
[1] 02 06 2017 22:34:05.120:INFO [launcher]: Launching browser Chrome with
unlimited concurrency
[1] 02 06 2017 22:34:05.156:INFO [launcher]: Starting browser Chrome
[1] 02 06 2017 22:34:06.742:INFO [Chrome 58.0.3029 (Windows 10 0.0.0)]:
Connected on socket GGConP8Ks64GubSYAAAA with id 70486747
[1] 02 06 2017 22:34:07.822:INFO [watcher]: Changed file
"D:/Project/temp/quickstart/src/app/app.component.js".
[1] 02 06 2017 22:34:07.837:INFO [watcher]: Changed file
"D:/Project/temp/quickstart/src/app/app.component.spec.js".
[1] 02 06 2017 22:34:07.856:INFO [watcher]: Changed file
"D:/Project/temp/quickstart/src/app/app.module.js".
[0] 10:34:07 PM - Compilation complete. Watching for file changes.
[1] 02 06 2017 22:34:07.865:INFO [watcher]: Changed file
"D:/Project/temp/quickstart/src/main.js".
[1] 02 06 2017 22:34:08.084:INFO [karma]: Delaying execution, these browsers
are not ready: Chrome 58.0.3029 (Windows 10 0.0.0)
Chrome 58.0.3029 (Windows 10 0.0.0): Executed 2 of 2 SUCCESS (0.159 secs /
0.149 secs)
Chrome 58.0.3029 (Windows 10 0.0.0): Executed 2 of 2 SUCCESS (0.117 secs /
0.112 secs)

Meteor deploy error on meteor host

I have an app without database functionality today I added some simple sitemap code with Mongo collection to app and test it locally all of things worked well but when I deployed application to meteor hosting with meteor deploy command my app crashed. I give this detail from meteor logs command:
[Wed Jun 24 2015 08:01:42 GMT+0000 (UTC)] WARNING MongoError: auth fails
at Object.Future.wait
(/meteor/dev_bundles/0.4.18/lib/node_modules/fibers/future.js:398:15)
at new MongoConnection (packages/mongo/mongo_driver.js:213:1)
at new MongoInternals.RemoteCollectionDriver
(packages/mongo/remote_collection_driver.js:4:1)
at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:1)
at Object.defaultRemoteCollectionDriver
(packages/underscore/underscore.js:750:1)
at new Mongo.Collection (packages/mongo/collection.js:98:1)
at app/server/sitemap.js:1:44
at app/server/sitemap.js:22:3
at
/meteor/containers/9d7d4183-ba55-fb30-3eb2-d6bceabe37e2/bundle/programs/server/boot.js:222:10
at Array.forEach (native)
- - - - -
at Object.toError
(/meteor/containers/9d7d4183-ba55-fb30-3eb2-d6bceabe37e2/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/utils.js:114:11)
at
/meteor/containers/9d7d4183-ba55-fb30-3eb2-d6bceabe37e2/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/db.js:1194:31
at
/meteor/containers/9d7d4183-ba55-fb30-3eb2-d6bceabe37e2/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/db.js:1903:9
at Server.Base._callHandler
(/meteor/containers/9d7d4183-ba55-fb30-3eb2-d6bceabe37e2/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/base.js:453:41)
at
/meteor/containers/9d7d4183-ba55-fb30-3eb2-d6bceabe37e2/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/server.js:487:18
at [object Object].MongoReply.parseBody
(/meteor/containers/9d7d4183-ba55-fb30-3eb2-d6bceabe37e2/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
at [object Object].<anonymous>
(/meteor/containers/9d7d4183-ba55-fb30-3eb2-d6bceabe37e2/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/server.js:445:20)
at [object Object].emit (events.js:95:17)
at [object Object].<anonymous>
(/meteor/containers/9d7d4183-ba55-fb30-3eb2-d6bceabe37e2/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:207:13)
at [object Object].emit (events.js:98:17)
[Wed Jun 24 2015 08:01:42 GMT+0000 (UTC)] ERROR Application crashed with code:
8
[Wed Jun 24 2015 08:01:42 GMT+0000 (UTC)] INFO STATUS running -> waiting
[Wed Jun 24 2015 08:01:45 GMT+0000 (UTC)] INFO HIT / 89.165.17.140
And this is my sitemap.xml code:
Pages = new Mongo.Collection("pages");
// https://atmospherejs.com/gadicohen/sitemaps
sitemaps.add('/sitemap.xml', function() {
var out = [], pages = Pages.find().fetch();
out.push({
page: '/',
lastmod: new Date(),
changefreq: 'always'
});
_.each(pages, function(page) {
out.push({
page: page.url,
lastmod: page.lastUpdated,
changefreq: 'weekly'
});
});
return out;
});
Please guide me how to fix this issue on deployment. On the local machine all things working right. )-:
After two days there is still a problem. My site is still not available and this is error:
This site has crashed.
Site administrators can examine the logs with:
meteor logs example.com
Retrying in x seconds...
It seems to be an error in the way the deploy scripts set up your deployment that has nothing to do with your code. To fix it, the app must first be deleted then re-deployed (or simply deployed under a different name):
meteor deploy xxx --delete
meteor deploy xxx

Resources