Error: Cannot find module 'assets-webpack-plugin' on Jenkins - node.js

Following error is seen while executing webpack as jenkins jobs.
webpack --config config/webpack.dev.js --progress --profile
Error: Cannot find module 'assets-webpack-plugin'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous>
npm ERR! Linux 3.16.0-33-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "build:dev"
npm ERR! node v0.10.45
npm ERR! npm v2.15.1
npm ERR! code ELIFECYCLE

This plugin didn't get installed due to incorrect node and npm version installed/used by Jenkins.
This scenario required following version upgrade on the ubuntu os on which jenkins is running:
node - v6.x.x
npm - v3.x.x

Related

Unable to use `npm run build` due to `\node_modules\tablemark\dist\index.js` being missing

I am trying to use npm run build and I am unable to run is as I am being told that \node_modules\tablemark\dist\index.js is not found. The error is as follows:
> node .
internal/modules/cjs/loader.js:456
throw e;
^
Error: Cannot find module 'D:\Avin Dev\dev-hearts\node_modules\tablemark\dist\index.js'
at createEsmNotFoundErr (internal/modules/cjs/loader.js:929:15)
at finalizeEsmResolution (internal/modules/cjs/loader.js:922:15)
at resolveExports (internal/modules/cjs/loader.js:450:14)
at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (D:\Avin Dev\dev-hearts\index.js:3:19)
at Module._compile (internal/modules/cjs/loader.js:1085:14) {
code: 'MODULE_NOT_FOUND',
path: 'D:\\Avin Dev\\dev-hearts\\node_modules\\tablemark\\package.json'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hearts#1.0.0 build: `node .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hearts#1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\avini\AppData\Roaming\npm-cache\_logs\2021-11-08T07_10_51_261Z-debug.log
So far I have tried:
Completely reinstalling npm.
Installing tablemark separately using npm install tablemark
My NPM version is: 6.14.15 and my Node version is v14.18.1

Cannot find module 'has-flag'

Getting below error while "npm run build" on server.On local machine working fine. Getting 500 response on server
node version:8.0
npm version: 5.0.3
Error: Cannot find module 'has-flag'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous>
(/usr/share/../../../node_modules/postcss/node_modules/supports-color/index.js:2:15)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ***#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ***#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Try npm install --save has-flag. It looks like supports-color is requiring has-flag to be installed but it isn't. If you need to install any other packages you can just type npm install.
The above didn't work for me, but deleting my node_modules and dist folders and rerunning npm install did.

Installing error when trying to npm install

I'm new to node.js, and I've been trying to npm install some modules - namely, cheerio, express and request. But I keep getting this:
npm WARN package.json node-web-scrape#0.0.1 No repository field.
npm WARN package.json node-web-scrape#0.0.1 No README data
npm WARN package.json node-web-scrape#0.0.1 No license field.
npm WARN retry will retry, error on last attempt: Error: EBUSY: resource busy or locked, rename 'C:\Users\user\AppData\Local\Temp\npm-16500-38020820\registry.npmjs.org\jsdom\-\jsdom-7.2.2.tgz.1538180439' -> 'C:\Users\user\AppData\Local\Temp\npm-16500-38020820\registry.npmjs.org\jsdom\-\jsdom-7.2.2.tgz'
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "cheerio"
npm ERR! node v4.4.7
npm ERR! npm v2.15.8
But the folder node_modules still appears in my directory. So OK, I try stuff on it. My main.js file has the following:
var request = require('request');
console.log("Hello, World!")
That's all it's got. Immediately, it breaks:
C:\Users\user\Documents\Crawler>node main
module.js:327
throw err;
^
Error: Cannot find module 'process-nextick-args'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\Users\user\Documents\Crawler\node_modules\request\node_modules\bl\node_modules\readable-stream\lib\_stream_duplex.js:21:23)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
Help?
Since you're using npm version 2.15.8, windows has a limit of folder depth. Update your npm to npm#3.
npm install -g npm#3
npm cache clear
Then, delete your node_modules/ before installing the npm modules(cheerio, express, request)
Source: BountySource

NPM: cannot find module './lib' after upgrading to Node.js 5.0 on OS X

Background
I just upgraded from Node.js v4.1.1 to v5.0.0 on my Mac. I used the node-v5.0.0.pkg installer from the node website because I don't have nvm or n installed, and I didn't install through Homebrew or MacPorts).
Problem
Now, every time I run npm I get the following error in my terminal:
Error: Cannot find module './lib'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/hawk/index.js:1:80)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm"
npm ERR! node v5.0.0
npm ERR! npm v3.3.6
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './lib'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
I can't even re-install NPM through the traditional method of running npm install -g npm because the package manager itself doesn't work.
How do I get NPM working again on my Mac?
Solution:
rm -rf /usr/local/lib/node_modules/npm
Reinstall node js v5.0.0
Other notes:
Looks like other people are running in to the same problem (see issue #3606). It sounds like a fix is in the works, so this issue will probably be resolved in the next release. In the interim, the only solution is to completely purge npm from your system and reinstall.

node-sass install failing on Jenkins

I'm trying to set up Jenkins to run Gulp but it keeps failing while attempting to install node-sass (a dependency of the gulp-sass plugin).
The issue seems to be that node is not finding a script file during install. I verified that script does actually exist in the project repository. When I pull my repo locally on the server and install it, it installs without a problem. That makes me think it's a Jenkins related environment issue.
Here's the error output:
> node-sass#2.1.1 install /root/.jenkins/jobs/odyssey-frontend/workspace/node_modules/gulp-sass/node_modules/node-sass
> node scripts/install.js
module.js:338
throw err;
^
Error: Cannot find module '/root/.jenkins/jobs/odyssey-frontend/workspace/node_modules/gulp-sass/node_modules/node-sass/scripts/install.js'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
npm ERR! Linux 3.14.35-28.38.amzn1.x86_64
npm ERR! argv "node" "/home/ec2-user/.linuxbrew/bin/npm" "install" "--production"
npm ERR! node v0.12.2
npm ERR! npm v2.7.6
npm ERR! code ELIFECYCLE
npm ERR! node-sass#2.1.1 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#2.1.1 install script 'node scripts/install.js'.
npm ERR! This is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node scripts/install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls node-sass
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /root/.jenkins/jobs/odyssey-frontend/workspace/npm-debug.log
module.js:338
throw err;
^
Error: Cannot find module 'gulp-sass'
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> (/root/.jenkins/jobs/odyssey-frontend/workspace/gulpfile.js:11:12)
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)
Build step 'Execute shell' marked build as failure
Finished: FAILURE
The Linux distribution is Amazon Linux AMI, Fedora-like. Trying to install node-sass ^2.0.1 via gulp-sass ^1.3.3.
I just tried the updated gulp-sass 2.0.0 with node-sass 3.0.0 and still have the same issue.
I removed all node-sass dependencies and it builds successfully now. So its really just that package; all other node packages install successfully.
I posted this on the Github project where it was answered: https://github.com/sass/node-sass/issues/941#issuecomment-100414516
Jenkins seems to run everything as sudo when building. NPM, as a security feature, won't run install scripts as sudo, hence the error. Adding a --unsafe-perm flag to the install script gets by this issue.

Resources