Unable to run test, too many files open - node.js

I am now unable to run tests, I was able to run the basic sum.js test on jests tutorial page, but am unable to test my react code. I've seen on other sites that moving the node 4.x fixes the issue, but not for me. Any help is appreciated.
C:\wamp\www\ccRelaunchWorkspace>node -v
v4.3.0
I am running windows 7
"devDependencies": {
"babel-jest": "^9.0.0",
"babel-polyfill": "*",
"babel-preset-es2015": "*",
"babel-preset-react": "*",
"jest-cli": "*",
"react-addons-test-utils": "~0.14.0"
},
"scripts": {
"test": "jest"
},
"jest": {
"scriptPreprocessor": "./node_modules/babel-jest",
"unmockedModulePathPatterns": [
"./node_modules/react",
"./node_modules/react-dom",
"./node_modules/react-addons-test-utils"
]
},
error:
Using Jest CLI v0.7.0
Error reading file: `C:\wamp\www\ccRelaunchWorkspace\node_modules\babel-preset-e
s2015\node_modules\babel-plugin-transform-es2015-parameters\node_modules\babel-t
raverse\node_modules\babel-code-frame\node_modules\chalk\node_modules\ansi-style
s\package.json`
C:\wamp\www\ccRelaunchWorkspace\node_modules\jest-cli\node_modules\node-haste\li
b\loader\ResourceLoader.js:88
throw err;
^
Error: EMFILE: too many open files, open 'C:\wamp\www\ccRelaunchWorkspace\node_m
odules\babel-preset-es2015\node_modules\babel-plugin-transform-es2015-parameters
\node_modules\babel-traverse\node_modules\babel-code-frame\node_modules\chalk\no
de_modules\ansi-styles\package.json'
at Error (native)
npm ERR! Test failed. See above for more details.
npm ERR! not ok code 0

I have completely remove all modules, and moved all of my modules into dependencies, instead of having some in devDependencies, and removed the version numbers on anything jest related and replaces the versions with * and then ran npm install

Related

vuejs - Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys'

Description
Everytime I run npm run serve the following error code appears:
ERROR Failed to compile with 1 error 15:34:19
This dependency was not found:
* ... in ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifie
r":"1a1491e2-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./no
de_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Ho
me.vue?vue&type=template&id=8dc7cce2&
To install it, you can run: npm install --save ...
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys'
Error from chokidar (C:\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys'
Error from chokidar (C:\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys'
Error from chokidar (C:\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys'
This error seemed to arise after adding a bootstrap carousel in my ./components/file.vue. although I fail to understand how the carroussel is linked to the npm chokidar package.
What I've tried
This issue being a duplicate of Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\DumpStack.log.tmp, I tried the solutions suggested without solving anything. I also tried npm install --save as suggested by the error code as well as npm cache clean --force. I have uninstalled the npm chokidar package, which didn't solve the issue, and deleted the C:\DumpStack.log.tmp file too. Finally I also installed the bootstrap-vue npm package which had no effect on the bug. None of the following have solved the issue althought I am aware this probably a pretty basic error.
package.json
{
"name": "vuejs-client",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"3": "^2.1.0",
"axios": "^0.21.1",
"bootstrap-vue": "^2.21.2",
"chokidar": "^3.5.1",
"core-js": "^3.6.5",
"vue": "^2.6.11",
"vue-router": "^3.5.1"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
I followed the following tutorial as frame of reference for what I want to achieve with this website: https://bezkoder.com/vue-node-express-mongodb-mevn-crud/
Well as stated, the error was pretty basic. I just had copy pasted the template for the carousel from Bootstrap and forgotten to replace the placeholders.
Sorry for the disturbances and may this help underline the fact that you really have to link the dots before asking the question as the solution can be quite basic.
Try this solution: Error: EBUSY: resource busy or locked, rmdir
This problem happened to me after installing JSON-SERVER globally and watching the server. I'm not sure if that was the cause but it happened right after the watching started.
I aborted the watch and the app wouldn't load with npm run serve.
I tried everything suggested by every forum post I could find including npm install, cache clean, cache clean --force, resetting my computer, disabling anti-virus and I have no malware software installed.
The only thing that finally worked was creating a whole new project and copying and pasting the files from the old corrupt one into a new one.
I don't understand why JSON Server should have anything to do with the cause unless the watching locks folders and renders the app unrunnable.
I will try again after I make a few copies of my app to experiment on because copying and pasting files is not a fun job unless your project is small enough.
UPDATE: I think the solution to this problem is don't install json-server globally. Install it locally and use npx json-server --watch to watch.
Otherwise a globally installed json-server will watch the entire drive through that app. That's why I had to copy the code into a new app uninstall json-server globally and reinstall it locally
.

How to use node modules in Laravel5.2 assets file

This time I am trying to use a npm web3 package in laravel 5.2 project. I am completely new using npm and that too inside laravel.
So far I have below things in my package.json file -
{
"private": true,
"devDependencies": {
"gulp": "^3.9.1"
},
"dependencies": {
"bootstrap-sass": "^3.0.0",
"laravel-elixir": "^2.0.0",
"web3": "^1.0.0-beta.36"
}
}
When I do npm install all the node dependencies are installed in node_modules inside root directory. Now I am trying to figure out how this packages can be bought in use inside public/assets/js/app.js file.
Do I also have to make node services running to use this packages?
npm version: 6.4.1
node version: v8.11.4
Your help is much appreciated.
Updated question - 10th Sep 2018
Downgraded my node package to 6.0 due to overcome few issues with 8.0 I was facing.
node version: v6.0.0
npm version: 3.8.6
New package.json:
{
"private": true,
"scripts": {
"prod": "gulp --production",
"dev": "gulp watch"
},
"devDependencies": {
"#types/node": "^10.9.4",
"gulp": "^3.9.1",
"laravel-elixir-rollup": "^0.3.3",
"laravel-elixir-webpack": "^1.0.1",
"require-dir": "^0.3.2"
},
"dependencies": {
"bootstrap-sass": "^3.0.0",
"laravel-elixir": "^5.0.0",
"web3": "^1.0.0-beta.36"
}
}
New gulpfile.json:
var elixir = require('laravel-elixir');
var path = require('path');
require('laravel-elixir-webpack');
elixir(function(mix) {
mix.webpack(
'./node_modules/web3/src/index.js',
'./public/js/web3-compiled.js'
);
});
When I run npm run dev in console, it stops finishes as below -
[digvijay#Digvijays-MacBook-Air:/var/www/html/estatebaron$ npm run dev
> # dev /private/var/www/html/estatebaron
> gulp watch
node_modules/nan
[17:10:07] Using gulpfile /private/var/www/html/estatebaron/gulpfile.js
[17:10:07] Starting 'watch'...
[17:10:07] Finished 'watch' after 18 ms
What I am expecting here is a js file name web3-compiled.js created in public/js directory, but that does not happen now. Am I missing anything here.
If you are using default laravel 5.2 configuration you're probably missing some lines in package.json see this
So to make it work run npm run dev, but make sure to configure your gulp correctly with gulpfile.js. Read more about this in the https://laravel.com/docs/5.3/elixir and https://github.com/gulpjs/gulp/tree/v3.9.1/docs

Issue with nsp scan

I am using nsp to scan for vulnerabilities. I see a strange behavior.
In scripts, dependency, devDependency section I have the following content
{
"scripts": {
"security-scan:nsp": "nsp check --threshold 10 --reporter json"
},
"dependencies": {
"joi": "10.x",
"dotenv": "4.0.0",
"nsp": "3.2.1"
},
"devDependencies": {
"lab": "14.x",
"code": "4.x",
"eslint": "4.1.1",
"eslint-plugin-import": "2.7.0"
}
}
If I run npm run security-scan:nsp i am getting some vulnerability but now if I move the nsp from dependency to devDependency and run npm run security-scan:nsp i dont get any vulnerability.Can anyone help me out here.
Nsp doesn't scan Dev dependencies. The new npm audit command does and it uses the same database of vulnerabilities, but doesn't have any of the formatting options of nsp.

Javascript (Jest) tests on Semaphore CI ruby project

I've had a Ruby on Rails project for several years set up with Semaphore CI. The Semaphore project is set to use Ruby 2.2.2 as it's language. Over time the project adopted npm with browserify and babelify, and we're using all the latest ES6 features. We added npm install as a setup step to our Semaphore build, and this was working fine.
Now we are starting to use Jest to test our javascripts, and this is working fine locally. But when I added npm test to our Semaphore test commands, npm test fails on semaphore CI with the following errors:
FAIL app/assets/javascripts/tests/selectors/conversations.test.js
● Test suite failed to run
SyntaxError: Unexpected token {
at _load_jsdom (node_modules/jest/node_modules/jest-cli/node_modules/jest-environment-jsdom/build/index.js:17:41)
FAIL app/assets/javascripts/tests/reducers/conversations.test.js
● Test suite failed to run
SyntaxError: Unexpected token {
at _load_jsdom (node_modules/jest/node_modules/jest-cli/node_modules/jest-environment-jsdom/build/index.js:17:41)
Test Suites: 2 failed, 2 total
Tests: 0 total
Snapshots: 0 total
Time: 0.65s
Ran all test suites.
npm ERR! Test failed. See above for more details.
This is some relavent information from the project's package.json:
"scripts": {
"test": "jest --debug --verbose"
},
"jest": {
"roots": [
"<rootDir>/app/assets/javascripts"
]
},
"dependencies": {
"babel-plugin-syntax-async-functions": "^6.3.13",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-regenerator": "^6.3.18",
"babel-polyfill": "^6.3.14",
"babel-preset-env": "^1.5.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-es2016": "^6.24.1",
"babel-preset-es2017": "^6.24.1",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"babelify": "^7.2.0",
"browserify": "^14.0.0",
"browserify-incremental": "^3.1.0",
"es6-promise": "^3.0.2",
"fetch": "^0.3.6"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-jest": "^22.1.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"bootstrap": "^4.0.0-beta.3",
"browserify": "^14.4.0",
"browserify-incremental": "^3.1.1",
"jest": "^22.1.1"
}
This is the .babelrc file located in the project :
{
"presets": ["env", "es2015", "es2016", "es2017", "stage-0", "react"]
}
Locally, I am on node v7.10.0. I SSH'ed into my Semaphore CI session and discovered that node v4.8.4 is installed there. I tried installing node v4.8.4 on my local machine and with that version installed, I get the same test errors (posted above) locally as I did on CI. So this is a node version issue.
I added:
"engines": {
"node": ">= 7.1.0"
}
to my package.json file, but that did not affect the node version installed on Semaphore.
So if I already have Ruby 2.2.2 chosen as my language and version in the Semaphore Build Settings, how to I change my node version?
Thanks in advance for the help.
It looks like SemaphoreCI is not using the same version of NPM as you. But you can set that within the build settings like this :
nvm install v8.9.4
npm install
npm test
You can test it out in the SSH
Ervin from Semaphore here,
To change the current Node.js version in the environment, whilst Ruby 2.2 is selected, add nvm use 7.1 to your setup steps. This will switch to the desired Node.js version and everything should work as expected. There's also an example of this in the docs.
Get in touch on support if you run into any issues.

npm ERR! Cannot read property 'pause' of undefined --Bluemix

I am trying to deploy a Sails.js app to Bluemix and we are getting the following error during the deploy stage in the toolchain on Bluemix (When the CF PUSH command is called):
npm ERR! Cannot read property 'pause' of undefined
I understand the trace goes to the npm-error.log file, however, I haven't been able to get to it as we cannot ssh in to see whats in the file as the application is in its "off" state after a bad deploy.
This same code was successfully deployed with both Cf push {app name}} and through a simple build and deploy toolchain in Bluemix just 8 days ago.
In the build stage I can run Npm install and npm update just fine. However, it seems to do this again in the deploy stage regardless and it fails. Here is some detail on this failure
NODE_ENV=production
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=true
Visit http://docs.cloudfoundry.org/buildpacks/node/index.html#vendoring
NODE_HOME=/tmp/app/.cloudfoundry/0/node
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
Restoring cache
Loading 3 from cacheDirectories (default):
- .npm
- .cache/yarn (not cached - skipping)
- bower_components (not cached - skipping)
Installing node modules (package.json) Building dependencies
sails#0.12.13 preinstall /tmp/app/node_modules/sails
node ./lib/preinstall_npmcheck.js
Sails.js Installation: Checking npm-version successful
npm ERR! Cannot read property 'pause' of undefined
npm ERR! /tmp/app/.npm/_logs/2017-09-09T17_02_48_660Z-debug.log
**ERROR** Unable to build dependencies: exit status 1
Failed to compile droplet
Exit status 223
Staging failed: Exited with status 223
Destroying container
npm ERR! A complete log of this run can be found in:
Successfully destroyed container
Package.json file
{
"name": "myApp",
"private": true,
"version": "0.0.1",
"description": "Stuff my app does",
"keywords": [
"Cool Apps"
],
"dependencies": {
"bcryptjs": "^2.4.3",
"cacheman": "^2.2.1",
"ejs": "2.3.4",
"elasticsearch": "^13.0.0-rc2",
"find-remove": "^1.0.1",
"fs": "0.0.1-security",
"grunt": "1.0.1",
"grunt-contrib-clean": "1.0.0",
"grunt-contrib-coffee": "1.0.0",
"grunt-contrib-concat": "1.0.1",
"grunt-contrib-copy": "1.0.0",
"grunt-contrib-cssmin": "1.0.1",
"grunt-contrib-jst": "1.0.0",
"grunt-contrib-less": "1.3.0",
"grunt-contrib-uglify": "1.0.1",
"grunt-contrib-watch": "1.0.0",
"grunt-sails-linker": "~0.10.1",
"grunt-sync": "0.5.2",
"include-all": "^1.0.0",
"jsonwebtoken": "^7.3.0",
"moment": "^2.18.1",
"moment-timezone": "^0.5.13",
"passport": "^0.2.x",
"passport-http-bearer": "^1.0.1",
"passport-idaas-openidconnect": "^1.1.0",
"passport-local": "^1.0.0",
"rc": "1.0.1",
"request": "^2.81.0",
"request-promise": "^4.2.0",
"sails": "~0.12.13",
"sails-disk": "~0.10.9",
"sails-mongo": "^0.12.2",
"stream": "0.0.2",
"uuid-1345": "^0.99.6",
"validator": "^7.0.0",
"natural-sort": "^1.0.0"
},
"scripts": {
"start": "node app.js"
},
"engines": {
"node": "^8.0.x",
"npm": "^5.0.x"
},
"main": "app.js",
"author": "Scott N",
"license": ""
}
Things I've tried so far.
-change node versions
-changed npm versions
-change dependencies versions to include the ^ prefix
-removed all dependencies but Sails in the package.json file
So Sails.js and the Nodebuildpack/Bluemix aren't playing well with each other.
Any help would be appreciated.
Thank you
It happens to me just the same. and I've to roll back the prev version of npm: 5.3.0 and it's working now. (BTW: macOS)
The error only happens when I update my npm version like this:
Update available 5.3.0 → 5.4.1
Run npm i -g npm to update
The best way to handle it is to update your package.json to use engines like so
"description": "a Sails application",
"keywords": [],
"engines": {
"node": "6.10.1",
"npm": "5.3.0"
},
Got this issue while trying to push to heroku which seems to be the npm version specified by #m-t, and also specifying the versions like above makes ibm bluemix pick it up as default node engine instead of using the latest stable version.
And don't forget to always specify your node and npm versions directly, instead of adding tilde or caret, this just to be safe. check https://stackoverflow.com/a/22345808/5836034 for more about tilde and caret
you can still check #sai-vennam answer here for more info
So I rolled back the sails version in the package.json file from 0.12 to 0.11 and it deployed fine. So CF PUSH and the newest sails version are not getting along on Bluemix. This was using Node 8.0 and NPM version ^5.0.x

Resources