internal modules cjs is not working after yarn upgraded to 1.13.0 - node.js

I have a react app which is based on react boilerplate. I am running the
following command:
cross-env NODE_ENV=development node --experimental-modules ./server/index.mjs
After upgrading yarn to 1.13.0, I am getting the following error:
(node:11137) ExperimentalWarning: The ESM module loader is experimental.
internal/modules/cjs/loader.js:677
module.reflect.onReady((reflect) => {
^
TypeError: Cannot read property 'onReady' of undefined
at Module.load (internal/modules/cjs/loader.js:677:22)
at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
at Function.Module._load (internal/modules/cjs/loader.js:598:3)
at Module.require (internal/modules/cjs/loader.js:705:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object.<anonymous> (/Users/mdjahidulislam/workspace/ifs/frontend/node_modules/psl/index.js:14:19)
at Module._compile (internal/modules/cjs/loader.js:799:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
at Module.load (internal/modules/cjs/loader.js:666:32)
at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Seems like module.reflect is undefined. In which scenario it can be undefined and how I can solve the problem.
Thanks in advance for any help and suggestions.

Finally solved it. It was all about nodejs version. I had nodejs version 11.* and then I downgraded it on 10.* and it solved the issue.

Related

Testcafe / Jenkins job failing TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function. Received undefined

I have a jenkins job that has worked consistently for the past 2 years running various front end tests, but recently I've gotten a stack trace from the job in jenkins that is continuously failing where I'm unsure what to do to fix it. The stack trace is listed below from the job:
TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function. Received undefined
at promisify (internal/util.js:279:11)
at Object.<anonymous> (/home/ec2-user/workspace/Sandbox_Verify/node_modules/testcafe-safe-storage/lib/file.js:18:33)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/ec2-user/workspace/Sandbox_Verify/node_modules/testcafe-safe-storage/lib/index.js:30:19)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/ec2-user/workspace/Sandbox_Verify/node_modules/testcafe/lib/dashboard/config-storage.js:3:33) {
code: 'ERR_INVALID_ARG_TYPE'
}
I am facing the same issue. Looks like there was a latest version of testCafe 1.19.0 version released yesterday after which the issue started. If you change your testcafe version to "testcafe": "1.18.6" or remove the ^ it should work. Or may be need to upgrade the nodejs version being used. Got the below warning
npm WARN notsup Unsupported engine for testcafe#1.19.0: wanted: {"node":">=14.0.0"} (current: {"node":"10.24.1","npm":"6.14.12"})
This is due to the testcafe global version. I think
you can check the global version by testcafe --version
and confirm your project installed version -> you can check your package.json file
If both are mismatch means, this issue could occur. So you should set BOTH version to be same
Ex: npm i -g testcafe#1.18.6
In package.json --> testcafe": "^1.18.6
in my case, its works perfectly. and also I have used firefox:headless
The cause of the issue is that you are using an outdated Node.js version.
The crypto.randomUUID function doesn't exist in Node.js 10.24.1.
Please update it to 14.x and all will work correctly.

how to solve this err in hardhat vs code

You are using a version of Node.js that is not supported by Hardhat,
and it may work incorrectly, or not work at all. Please, make sure you
are using a supported version of Node.js. To learn more about which
versions of Node.js are supported go to
https://hardhat.org/nodejs-versions
An unexpected error occurred:
Error: Cannot find module '#nomiclabs/hardhat-waffle'
Require stack:
- D:\3.1\dppa\hardhat.config.js
- D:\3.1\dppa\node_modules\hardhat\internal\core\config\config-loading.js
- D:\3.1\dppa\node_modules\hardhat\internal\cli\cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
at Function.Module._load (node:internal/modules/cjs/loader:780:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (D:\3.1\dppa\hardhat.config.js:1:1)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:827:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'D:\\3.1\\dppa\\hardhat.config.js',
'D:\\3.1\\dppa\\node_modules\\hardhat\\internal\\core\\config\\config-loading.js',
'D:\\3.1\\dppa\\node_modules\\hardhat\\internal\\cli\\cli.js'
]
}
PS D:\3.1\dppa>
It looks like you are trying to run the sample project and are missing plugins.
As stated here, you need to install some plugins for the sample project with the following command.
npm install --save-dev #nomiclabs/hardhat-waffle ethereum-waffle chai #nomiclabs/hardhat-ethers ethers
Besides that, as stated in the provided link, you should use the latest LTS of Node.js, which is Node.js 16 and can be downloaded here

Cannot import cloudinary in nodeJS with "navigator undefined" error

I recently installed cloudinary via npm and cannot import it in my nodeJS backend due to the following error.
(base) feiwu#Feis-MacBook-Pro backend % node server.js
/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:1168
var useAgent = navigator && navigator.userAgent || '';
^
ReferenceError: navigator is not defined
at Module../src/namespace/cloudinary-core.js (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:1168:16)
at __webpack_require__ (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:37:30)
at /Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:101:18
at /Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:104:10
at webpackUniversalModuleDefinition (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:10:20)
at Object.<anonymous> (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:17:3)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary/lib/utils/index.js:48:57)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
I have found nothing so far about this error and would like to know if someone know about this issue ?
This error is from cloudinary's end. Fix this error with npm i cloudinary-core.
Started happening to me around 15 hours ago as well.
Cloudinary had just released a new version to its JS SDK (version 2.12.2) that fixes this issue.
installing cloudinary-core helped me get rid of this error
npm i cloudinary-core
This issue was introduced recently in Cloudinary version 1.28.0.
https://www.npmjs.com/package/cloudinary/v/1.28.0
The issue reported on github here : https://github.com/cloudinary/cloudinary_npm/issues/524
I was able to fix this issue by pointing cloudinary to 1.27.1
"cloudinary": "1.27.1"
Cloudinary guys have fixed this issue here : https://github.com/cloudinary/cloudinary_js/pull/281.

ERR_PACKAGE_PATH_NOT_EXPORTED : Package subpath './dist/pako.es5.js' is not defined by "exports"

I have an issue with the deployment of a node app to production.
When I try to execute with Node a script I get the following error:
internal/modules/cjs/loader.js:498
throw new ERR_PACKAGE_PATH_NOT_EXPORTED(basePath, mappingKey);
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/pako.es5.js' is not defined by "exports" in /opt/iul/sat_web_lfr/node_modules/pizzip/node_modules/pako/package.json
at applyExports (internal/modules/cjs/loader.js:498:9)
at resolveExports (internal/modules/cjs/loader.js:514:23)
at Function.Module._findPath (internal/modules/cjs/loader.js:642:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1017:27)
at Function.Module._load (internal/modules/cjs/loader.js:899:27)
at Module.require (internal/modules/cjs/loader.js:1090:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (/opt/iul/sat_web_lfr/node_modules/pizzip/js/flate.js:5:12)
at Module._compile (internal/modules/cjs/loader.js:1201:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
at Module.load (internal/modules/cjs/loader.js:1050:32)
at Function.Module._load (internal/modules/cjs/loader.js:938:14)
at Module.require (internal/modules/cjs/loader.js:1090:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (/opt/iul/sat_web_lfr/node_modules/pizzip/js/compressions.js:14:19)
at Module._compile (internal/modules/cjs/loader.js:1201:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
at Module.load (internal/modules/cjs/loader.js:1050:32)
at Function.Module._load (internal/modules/cjs/loader.js:938:14)
at Module.require (internal/modules/cjs/loader.js:1090:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (/opt/iul/sat_web_lfr/node_modules/pizzip/js/utils.js:7:20) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
However when I execute this script on the testing server works fine.
We even copy and paste the node modules folder from the testing server to the production server but the error is the same.
I think is an error in some external package but I don't understand how the same configuration can have this kind of error depending on the system.
I've tried to update npm from 6.14.5 to 7.23.0 but the error persists.
Both testing and production server uses the same version of Node, 14.X
The only possibility remaining is that I'm using a different NODE_ENV variable between the 2 servers but looking at the error message it's seems unlikely.
Thanks in advance.

pptxgenjs 3.0 node js ReferenceError: JSZip is not defined

On Friday January 3rd, 2019, pptxgenjs library has been upgraded from version 2.6.0 to 3.0.0. This being said when I upgraded the package and attempted to start my server it gave me the following error
ReferenceError: JSZip is not defined
at Object.<anonymous> (/Users/a.farghaly/Desktop/up-api/node_modules/pptxgenjs/dist/pptxgen.min.js:2:190018)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object.<anonymous> (/Users/a.farghaly/Desktop/upsiide-api/utility/powerpoint/ppt.js:1:19)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
[nodemon] app crashed - waiting for file changes before starting...
This being said JSZip works fine with the previouse version (2.6.0)
I would be thankful if anyone can help me with this issue
A screenshot from npmjs.com main page trying pptxgenjs v3.0.0
It's a bug: https://github.com/gitbrent/PptxGenJS/issues/638
Using https://github.com/gitbrent/PptxGenJS.git#2cee3f0c412106aefb1f87fc16bfef78ae5521a7 and it works with NodeJS.
It’s a bug where Node was referencing dist/pptxgenjs.min.js intead of dist/pptxgenjs.min.js. In pptxgenjs.min.js jszip library is not defined

Resources