node-sass install failing on Jenkins - node.js

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.

Related

Error when running vuetifyjs template

I have successfully installed a vuetifyjs template using the command
vue init vuetifyjs/webpack-advanced
it was successfully installed but when I tried to use the command npm run dev I had the following error message:
C:\Users\Muse\Documents\vuetify>npm run dev
vuetify#1.0.0 dev C:\Users\Muse\Documents\vuetify
node build/dev-server.js
fs.js:1657
binding.lstat(baseLong);
^
Error: ENOENT: no such file or directory, lstat 'C:\Users\Muse\Documents\vuetify\test'
at Object.realpathSync (fs.js:1657:15)
at resolve (C:\Users\Muse\Documents\vuetify\build\webpack.base.conf.js:8:13)
at Object. (C:\Users\Muse\Documents\vuetify\build\webpack.base.conf.js:35:35)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vuetify#1.0.0 dev: node build/dev-server.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vuetify#1.0.0 dev 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\Muse\AppData\Roaming\npm-cache_logs\2017-08-31T09_19_06_701Z-debug.log
You just need to create a test folder and give it access.
It's a bug with webpack-advanced template
Fore install your project dependencies
npm install -f
Then, make a folder named "test" in your root project
mkdir test
It's a bug caused by vuetifyjs/webpack-advanced

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

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

npm install: Error : Cannot find module 'tough-cookie'

I have removed and reinstalled node.js many times
> node -v
4.5.0
> npm -v
3.3.6
Once I run the command npm install request I get the following error :
Error: Cannot find module 'tough-cookie'
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\Generic User\AppData\Roaming\npm\node_modules\npm\node_modules\request\lib\cookies.js:3:13)
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)
at require (internal/module.js:12:17)
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Generic User\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "request"
npm ERR! node v4.5.0
npm ERR! npm v3.3.6
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'tough-cookie'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
You probably will tell me to run
> npm update -g npm
I get the same error for this command too.
It looks like your version 3 npm install is broken, for some reason. It'd be interesting to know whether this path exists:
C:\Users\Generic User\AppData\Roaming\npm\node_modules\npm\node_modules\request\node_modules\tough-cookie
and whether it contains a valid package, etc.
With your npm v 3 install, broken, none of the npm install or update commands will work (as they'll need the request module). However, you might be able to roll back npm - as version 4.5.0 of Node.js installs npm version 2.15.9 and it will still be there:
> npm uninstall -g npm
That should leave you with:
> npm -v
2.15.9
Before re-installing npm v 3, clear the cache:
> npm cache clear
> npm install -g npm
However, before you re-install version npm v 3, it would be interesting to see if you are able to install request with npm v 2.
In my case it was a .lock file that caused this error, deleting the file fixed it. Same problem and solution was reported here: https://github.com/sass/node-sass/issues/2019
Is there a package.json file in the folder you are running node from?
If there is a package.json, then running :
npm install request
will not have the desired effect, in fact npm will just try and install whatever module is described in package.json
Have you tried npm install tough-cookie
it has worked for me
its browser issue ... please try to open it in chrome incognito windows or firefox private window and delete cookies

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.

NPM broken mime-db missing

I had to reinstall Nodejs on my Macbook when I ran into an issue with npm.
No matter what I did I always got this output:
$ npm
Error: Cannot find module 'mime-db'
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> (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/form-data/node_modules/mime-types/index.js:2:10)
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)
npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'mime-db'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
I did not understand who this was happening. So I installed it one more time in hope that it would be fixed. No luck.
I did fix it after a wasting to much time. That is why I put it on here so that if anybody may walk into the same problem they solve it sooner then I did.
I used following command on node command prompt
npm install mime-db
It gave me warning: unmet dependency that it requires version 1.12 of mime-db, but it will download version 1.21 of mime-db
i ran the same command again i.e.
npm install mime-db
It solved my issue
Good Luck.
Another solution:
I was trying out something else, then I upgraded node package, downloading from node website and installing it, then i did not face this issue.
Thank you
After looking in the repo of mime-db and saw that I was missing this file in the module that was installed with the pkg. I added this file and now it works.
Good luck!
I deleted mime-db from the node_modules folder. Then I ran
npm i mime-db
That solved my problem.

Resources