Jenkins build automation unable to run Gulp commands script - node.js

I am trying to create a very simple build project in Jenkins. I have added only single build step as of now but its failing while running the build.
The step I have added is as follows:
This is only the NodeJS script step I wanted to run as of now. Once it succeed I will go ahead with full build steps.
I checked many SO question regarding this and have done all the necessary configurations like follows:
Already set Global Environment variable in Jenkins as:
And Global tool configuration like:
Still I am getting below error after running the build:
[workspace] $ node.exe C:\Windows\TEMP\hudson921629484097398968.js
module.js:471
throw err;
^
Error: Cannot find module 'gulp'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Windows\TEMP\hudson921629484097398968.js:1:74)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
Build step 'Execute NodeJS script' marked build as failure
Finished: FAILURE
Note: I already tried executing npm install gulp#~3.9.1 command.

Related

stt.node version incompatible with electron

I'm getting below error when trying to launch the application.
This is after I deleted node_modules and re-ran npm i to pull packages again
App threw an error during load
node_modules/electron/dist/resources/default_app.asar/main.js:113
Error: Cannot find module '/home/korodarn/projects/mygit/sight-words-solid-electron/node_modules/stt/lib/binding/v1.4.0/linux-x64/electron-v17.4/stt.node'
Require stack:
- /home/korodarn/projects/mygit/sight-words-solid-electron/node_modules/stt/index.js
- /home/korodarn/projects/mygit/sight-words-solid-electron/dist/main/index.cjs
- /home/korodarn/projects/mygit/sight-words-solid-electron/node_modules/electron/dist/resources/default_app.asar/main.js
-
at Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
at Function.n._resolveFilename (node:electron/js2c/browser_init:249:1105)
at Module._load (node:internal/modules/cjs/loader:785:27)
at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/korodarn/projects/mygit/sight-words-solid-electron/node_modules/stt/index.js:24:17)
at Module._compile (node:internal/modules/cjs/loader:1116:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1169:10)
at Module.load (node:internal/modules/cjs/loader:988:32)
I've tried electron-rebuild ( invoked with node_modules/.bin/electron-rebuild ) and it completes successfully but it seems to only rebuild the canvas dependency based on the output.
I am not able to follow the coqui stt documentation well enough to know where to go next.

Serverless Node TypeScript app can't import module

I'm tired of this error! This is Serverless app with Lambda in AWS. Locally it works perfectly. Testing locally didn't work for load of other reasons. I'm testing in staging. Yet I'm getting this error:
Unable to import module 'src/engine/handler': Error
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous>(/var/task/src/engine/controllers/image.js:43:12)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
I followed all the steps advised elsewhere including: moving all dependencies to dependencies (out of dev), installing serverless and all. I'm using Node 6.10.3 and TypeScript 3.1. Can you help?
If you're trying host your nodejs projects which has so many dependencies not related to aws services inside, you better zip your projects in S3 first then import lambda from S3.

Unable to import module 'index': Error in aws cloud watch logs while using claudia.js

Unable to import module 'index': Error in aws cloud watch logs.
upload lambda using claudia works fine but api does not work and cloud watch logs displays following errors:
Unable to import module 'index': Error
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/task/node_modules/request/request.js:12:21)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
I have some code that only works in local node version (so it passes validation locally), but fails once it goes to server version. use nvm to run node locally for lambda projects and you'll catch those errors before deployment
so running : "npm install npm" in project directory solves the issue. then uploaded that again to aws using claudia.
all works fine.
thanks Gojko Adzic.

Trouble getting Mocha, node.js and WebStorm to work with each other

I have been following the instructions to install Mocha with WebStorm found here: https://www.jetbrains.com/help/webstorm/2017.1/testing-javascript-with-mocha.html#d194239e92
I have set the configurations to run files that match the pattern: **/*.spec.js
node interpreter: /usr/bin/node
working directory:/home/web/app
mocha package:/home/web/app/node_modules/mocha
I am writing in TypeScript which is converted to ES6, the output of which is what I'm attempting to test. However I get this error which I don't understand and so don't really know where to begin looking to resolve.
I don't understand why it is looking for "ts-node", considering it's only supposed to look for "spec.js" files. and past that, I don't understand why the folder it is looking for in ts-node is missing. I have uninstalled then re-installed ts-node a couple times, neither of which yielded the sought after folder... I have no clue as to how to proceed or even what further information is needed to help resolve this issue.
Any help would be appreciated. I just want to test my application and this is proving to be a real headache.
Here is the error:
/usr/bin/node /home/web/app/node_modules/mocha/bin/_mocha --ui bdd
--reporter /opt/webstorm/ws/plugins/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js
**/*.spec.js TypeError: The specified path does not exist: /home/web/app/node_modules/ts-node/tests
at resolveSync (/home/web/app/node_modules/ts-node/node_modules/tsconfig/src/tsconfig.ts:72:9)
at Object.loadSync (/home/web/app/node_modules/ts-node/node_modules/tsconfig/src/tsconfig.ts:140:16)
at readConfig (/home/web/app/node_modules/ts-node/src/index.ts:418:18)
at Object.register (/home/web/app/node_modules/ts-node/src/index.ts:176:18)
at Suite. (/home/web/app/node_modules/ts-node/src/index.spec.ts:190:5)
at Object.create (/home/web/app/node_modules/mocha/lib/interfaces/common.js:114:19)
at context.describe.context.context (/home/web/app/node_modules/mocha/lib/interfaces/bdd.js:44:27)
at Suite. (/home/web/app/node_modules/ts-node/src/index.spec.ts:189:3)
at Object.create (/home/web/app/node_modules/mocha/lib/interfaces/common.js:114:19)
at context.describe.context.context (/home/web/app/node_modules/mocha/lib/interfaces/bdd.js:44:27)
at Object. (/home/web/app/node_modules/ts-node/src/index.spec.ts:13:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at /home/web/app/node_modules/mocha/lib/mocha.js:230:27
at Array.forEach (native)
at Mocha.loadFiles (/home/web/app/node_modules/mocha/lib/mocha.js:227:14)
at Mocha.run (/home/web/app/node_modules/mocha/lib/mocha.js:495:10)
at Object. (/home/web/app/node_modules/mocha/bin/_mocha:460:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:505:3
Process finished with exit code 1
I figured it out, my path was from the root of my project, which contained node_modules, and so the node_modules directory was being tested, causing errors from tests inside the ts-node folder. the fix was to exclude node_modules directory from the specified path for test modules.

Mongoose: Error cannot find module debug

I'm building a basic MEAN webapp and am new to the stack. I have the front end running, but as soon as I add the following lines to app.js:
var mongoose = require('mongoose');
require('./models/test');
mongoose.connect('mongodb://localhost:3000/design-data-test');
I get the following error in terminal:
Error: Cannot find module 'debug'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/username/node_modules/mongoose/node_modules/mquery/lib/mquery.js:11:13)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
And all of my front end code stops running. Mongodb is running on the default port.
How would I go about resolving this error?
For future visitors: You are probably missing a dependency. Make sure you run this first:
npm install
... before you run your app with npm start or node <app>
I think this may happen if you have a child dependency on debug through another package (for example express or mongoose) but you did not provide the dependencies' package.json files with the deployed application which makes node.js unable to locate debug.

Resources