I got the below error when I'm trying to run npm install. Error Message:
taskRepository: Failed to require task module for setTimestamp: require() of ES Module ......\node_modules\dateformat\lib\dateformat.js from .....\setTimestamp.js not
supported.
Instead change the require of dateformat.js in .....\setTimestamp.js to a dynamic import() which is available in all CommonJS modules.
In setTimestamp.js file, we have
const stringReplacer = require("#ui5/builder").processors.stringReplacer;
const df = require("dateformat");
This is a SAPUI5 based cloud application and we've 2 package.json files.
Under Root folder:
"version": "1.2.0",
"devDependencies": {
"#ui5/builder": "^2.11.5",
"#ui5/cli": "^2.14.10",
"#wdio/cli": "7.23.0",
"#wdio/cucumber-framework": "7.23.0",
"#wdio/junit-reporter": "7.23.0",
"#wdio/local-runner": "7.23.0",
"#wdio/selenium-standalone-service": "7.23.0",
"#wdio/spec-reporter": "7.23.0",
"chai": "^4.3.6",
"chromedriver": "^104.0.0",
"cucumber-html-reporter": "5.5.0",
"nyc": "^15.1.0",
"opa-e2e": "^1.0.11",
"request": "^2.88.2",
"request-promise": "^4.2.6",
"shelljs": "^0.8.5",
"type": "module",
"wdio-chromedriver-service": "^7.3.2",
"wdio-cucumber-reporter": "0.0.2",
"wdio-cucumberjs-json-reporter": "^4.4.3"
},
"resolutions": {
"terser": ">=5.14.2",
"markdown-it": ">=12.3.2",
"marked": ">=4.0.10",
"shelljs": ">=0.8.5",
"ejs": ">=3.1.7",
"node-fetch": ">=2.6.7",
"got": ">=11.8.5",
"follow-redirects": ">=1.14.8",
"minimist": ">=1.2.6"
}
Inner one:
"ui5": {
"dependencies": [
"ui5-middleware-livereload",
"ui5-middleware-simpleproxy",
"ui5-middleware-servestatic",
"#dwc/ui5-middleware-dwc"
]
},
"devDependencies": {
"#dwc/ui5-middleware-dwc": "^1.4.2-20220817085704",
"#ui5/cli": "^2.14.10",
"dateformat": "^5.0.3",
"env-cmd": "^10.1.0",
"eslint": "^8.22.0",
"karma": "6.4.0",
"karma-chrome-launcher": "^3.1.1",
"karma-coverage": "^2.2.0",
"karma-junit-reporter": "^2.0.1",
"karma-qunit": "^4.1.2",
"karma-sinon": "^1.0.5",
"karma-ui5": "2.4.0",
"nyc": "^15.1.0",
"qunitjs": "^2.4.1",
"rimraf": "^3.0.2",
"shelljs": "^0.8.5",
"start-server-and-test": "^1.14.0",
"ui5-middleware-livereload": "^0.7.0",
"ui5-middleware-servestatic": "^0.4.0",
"ui5-middleware-simpleproxy": "^0.9.1",
"wdio-chromedriver-service": "7.3.2"
},
"resolutions": {
"terser": ">=5.14.2",
"markdown-it": ">=12.3.2",
"marked": ">=4.0.10",
"ua-parser-js": ">=0.7.24",
"log4js": ">=6.4.0",
"karma": ">=6.3.16",
"follow-redirects": ">=1.14.8",
"minimist": ">=1.2.6"
}
I tried to fix this issue by using:
npm i node-fetch#2.6.1
Or, in package.json file , wrote "type": "module" etc.
Ref: Instead change the require of index.js, to a dynamic import() which is available in all CommonJS modules
Could anyone please help me to solve the error? Any help would be much appreciate.
Request: Please don't close the question. I know it's duplicate question, however I couldn't find any solution, tried how much I found.Thank you
I got the same error requiring node-fetch. The solution was
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
Related
I have created a docusaurus project. It was working fine. I added material ui search bar in the landing page. I am using github actions to deploy the project(CI/CD). Now when i push the code, iam getting this error.
[ERROR] TypeError: dep.getModuleEvaluationSideEffectsState is not a function
at NormalModule.getSideEffectsConnectionState (/github/workspace/website/node_modules/webpack/lib/NormalModule.js:1126:23)
at /github/workspace/website/node_modules/webpack/lib/optimize/SideEffectsFlagPlugin.js:244:19
at Hook.eval [as call] (eval at create (/github/workspace/website/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:12:16)
at Hook.CALL_DELEGATE [as _call] (/github/workspace/website/node_modules/tapable/lib/Hook.js:14:14)
at Compilation.seal (/github/workspace/website/node_modules/webpack/lib/Compilation.js:2804:42)
at /github/workspace/website/node_modules/webpack/lib/Compiler.js:1187:20
at /github/workspace/website/node_modules/webpack/lib/Compilation.js:2757:4
at _next2 (eval at create (/github/workspace/website/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:35:1)
at eval (eval at create (/github/workspace/website/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:71:1)
at /github/workspace/website/node_modules/webpack/lib/FlagDependencyExportsPlugin.js:385:11
I am not sure how to solve this. I have also attached package.json file.
{
"scripts": {
"examples": "docusaurus-examples",
"start": "docusaurus start",
"build": "docusaurus build",
"serve": "docusaurus serve",
"publish-gh-pages": "docusaurus-publish",
"write-translations": "docusaurus-write-translations",
"version": "docusaurus-version",
"rename-version": "docusaurus-rename-version",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"docusaurus": "docusaurus"
},
"engines": {
"node": ">=16.14.0"
},
"dependencies": {
"#azure/msal-browser": "^2.28.0",
"#azure/msal-react": "^1.4.4",
"#docusaurus/core": "^2.0.0-rc.1",
"#docusaurus/plugin-client-redirects": "^2.1.0",
"#docusaurus/plugin-content-docs": "^2.0.0-rc.1",
"#docusaurus/preset-classic": "^2.0.0-rc.1",
"#emotion/react": "^11.10.4",
"#emotion/styled": "^11.10.4",
"#fortawesome/react-fontawesome": "^0.1.18",
"#material-ui/core": "^4.12.4",
"#mui/material": "^5.10.8",
"axios": "^0.27.2",
"bootstrap": "^5.1.3",
"chart.js": "^3.8.0",
"clsx": "^1.1.1",
"docker": "^1.0.0",
"docusaurus": "^1.14.7",
"docusaurus-lunr-search": "^2.1.15",
"docusaurus-pdf": "^1.2.0",
"docusaurus2-dotenv": "^1.4.0",
"env-cmd": "^10.1.0",
"jquery": "^3.6.0",
"moment": "^2.29.4",
"react": "^17.0.2",
"react-bootstrap": "^2.4.0",
"react-chartjs-2": "^4.3.1",
"react-dom": "^17.0.2",
"react-icons": "^4.4.0",
"react-markdown-editor-lite": "^1.3.2",
"react-paginate": "^8.1.3",
"react-player": "^2.10.1",
"react-scripts": "^5.0.1"
}
}
Can someone help me with this?
Are you using the plugin docusaurus2-dotenv?
We found the same problem here, and the root cause is this plugin. We remove this plugin from the package.json and from the docusaurus.config.js. We replaced it inside the docusaurus.config.js with the plugin docusaurus-plugin-dotenv, like this:
// Before
plugins:
[
// Other plugins
['docusaurus2-dotenv', { systemvars: true }],
]
// After
plugins:
[
// Other plugins
[
'docusaurus-plugin-dotenv',
{
path: "./.env",
systemvars: true,
}
]
]
This error occurs because the plugin 'docusaurus2-dotenv' is depreciated, although the docusaurus documentation itself recommends using it.
After removing it from our project, we noticed that even some vulnerabilities have gone away.
Here's the link of the new plugin: docusaurus-plugin-dotenv
EDIT: This question is related to #56558281 however it's two years old and hasn't been answered
I'm refactoring a few apps we have and tried moving a block of JS code from one NestJs app into another Nuxt app. After installing the dependencies I get this error:
These dependencies were not found: friendly-errors 11:04:41
friendly-errors 11:04:41
* child_process in ./node_modules/google-auth-library/build/src/auth/googleauth.js friendly-errors 11:04:41
* fs in ./node_modules/google-auth-library/build/src/auth/googleauth.js, ./node_modules/google-p12-pem/build/src/index.js and 4 others
friendly-errors 11:04:41
To install them, you can run: npm install --save child_process fs
I tried running npm install --save child_process fs without luck
Tried deleting node modules and clearing the cache then reinstalling with no luck
and I tried adding this block as per this answer without luck either
"browser":{
"child_process": false
}
Package.json
...
"dependencies": {
"#nuxt/types": "^2.14.5",
"#nuxtjs/apollo": "^4.0.1-rc.5",
"#nuxtjs/axios": "^5.12.5",
"#nuxtjs/gtm": "^2.2.2",
"#nuxtjs/vuetify": "^1.11.0",
"apollo-link-http": "^1.5.17",
"child_process": "^1.0.2",
"filestack-js": "^3.16.0",
"googleapis": "^39.2.0",
"google-auth-library": "^3.1.2",
"graphql": "^15.5.1",
"graphql-tag": "^2.12.5",
"isomorphic-fetch": "^3.0.0",
"net": "^1.0.2",
"nuxt": "^2.0.0",
"nuxt-i18n": "^6.12.2",
"nuxt-webfontloader": "^1.1.0",
"pluralize": "^8.0.0",
"readline": "^1.3.0",
"tls": "^0.0.1",
"typescript": "^3.0.0",
"url-slug": "^2.2.0",
"vue": "^2.6.11",
"vue-apollo": "^3.0.7",
"vue-infinite-loading": "^2.4.5",
"vuedraggable": "^2.24.3"
},
"devDependencies": {
"#mdi/font": "^5.3.45",
"#nuxt/typescript-build": "^2.0.3",
"#nuxtjs/eslint-config-typescript": "^3.0.0",
"#nuxtjs/eslint-module": "^2.0.0",
"#types/pluralize": "0.0.29",
"#vue/test-utils": "^1.0.0-beta.27",
"babel-eslint": "^10.0.1",
"babel-jest": "^26.0.1",
"deepmerge": "^4.2.2",
"eslint": "^7.9.0",
"eslint-plugin-nuxt": ">=0.4.2",
"eslint-plugin-prettier": "^3.0.1",
"fibers": "^5.0.0",
"jest": "^26.0.1",
"pug": "^2.0.3",
"pug-plain-loader": "^1.0.0",
"sass": "^1.26.11",
"sass-loader": "^8.0.2",
"typed-graphqlify": "^2.2.3",
"vue-class-component": "^7.1.0",
"vue-jest": "^4.0.0-beta.3",
"vue-property-decorator": "^9.0.0"
},
"browser":{
"child_process": false
}
I created an API including using of hummus.js. After testing it local, I uploaded my new API Build on my Server (Ubuntu Root + Plesk Onyx) and npm install my package.json (with Plesk => Output: Installation complete Status: Success). But my new Build doesn't work. After debugging my Code I detect the error. My API get an Internal Error after require one module (Tested this with that Code)
try {
var hummus = require('hummus');
var fillClass = require('../classes/fillform').fillForm;
}
catch (e) {
res.send("ERROR HUMMUS")
}
Run this Code I get = ERROR HUMMUS
I thought that the hummus path doesn't exist but with:
try {
res.send(require.resolve("hummus")).end();
} catch(e) {
res.send("not found").end();
process.exit(e.code);
}
I get the path to the module (hummus). Although all file in this folder exists.
(Other modules like async, fs etc works well)
What I do wrong? What should I do?
Greetings
edit Package.json
{"name": "XXX-API",
"version": "1.0.9",
"main": "server.js",
"dependencies": {
"archiver": "^2.0.0",
"array-sum": "^1.0.0",
"async": "^2.5.0",
"big-integer": "^1.6.24",
"body-parser": "^1.17.2",
"child_process": "^1.0.2",
"cors": "^2.8.3",
"curl": "^0.1.4",
"express": "^4.15.3",
"file-encryptor": "^0.1.1",
"fs": "0.0.1-security",
"ftp": "^0.3.10",
"ftp-client": "^0.2.2",
"ftps": "^1.1.0",
"german-tax-id-validator": "^1.0.3",
"https": "^1.0.0",
"hummus": "^1.0.80",
"ibantools": "^1.3.0",
"jsftp": "^2.0.0",
"leading-zeros": "^1.0.1",
"lodash": "^4.17.4",
"mysql": "^2.13.0",
"node-datetime": "^2.0.0",
"node-pdffiller": "0.0.7",
"node-uuid": "^1.4.8",
"node-zip": "^1.1.1",
"nodemailer": "^4.0.1",
"pad-right": "^0.2.2",
"pdfkit": "^0.8.3",
"phantomjs": "^2.1.7",
"pug": "^2.0.0-rc.2",
"request-promise": "^4.2.1",
"requestify": "^0.2.5",
"shortid": "^2.2.8",
"slack-node": "^0.1.8",
"uid": "0.0.2",
"xmlbuilder": "^9.0.4"
}
}
Pls write the error to log.
... catch (err){
logger.debug(err.stack)
}
No better way than error stack.
On an existing project, that have worked fine over many months and which is already in the AppStores for both iOS and Android, we've got now a break on development with this error:
babelHelpers.typeof is not a function
All what we've done was to try to upgrade an RN-0.26-based Application to a newer version. But even after a rollback the error remains.
We cleared watchman, resetted the packager multiple times. Nothing helped here.
Our package.json looks like this:
{
"version": "0.0.1",
"private": true,
"scripts": {
"reset": "rm -rf node_modules/ && npm cache clear && watchman watch-del-all && npm i",
"start": "node node_modules/react-native/local-cli/cli.js start --reset-cache",
"testflight": "fastlane beta",
"android-device": "adb reverse tcp:8081 tcp:8081 && react-native run-android",
"lint": "jslint **.js",
"test": "mocha test/",
"generate-apk": "cd android && ./gradlew assembleRelease && open ./app/build/outputs/apk/",
"install-apk": "cd android && ./gradlew installRelease",
},
"devDependencies": {
"jshint": "latest",
"mocha": "latest",
"eslint": "^2.3.0",
"eslint-config-standard": "^5.1.0",
"eslint-config-standard-react": "^2.3.0",
"eslint-plugin-promise": "^1.1.0",
"eslint-plugin-react": "^4.1.0",
"eslint-plugin-react-native": "^1.0.0",
"eslint-plugin-standard": "^1.3.2"
},
"dependencies": {
"apsl-react-native-button": "^2.5.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.11.1",
"es6-promisify": "^4.1.0",
"fetch-stuff": "^1.0.1",
"iap-receipt-validator": "^1.0.2",
"immutable": "^3.8.1",
"js-sha256": "^0.3.0",
"keymirror": "^0.1.1",
"lodash.difference": "^4.3.0",
"lodash.find": "^4.4.0",
"lodash.partialright": "^4.1.4",
"lodash.remove": "^4.5.0",
"lodash.shuffle": "^4.0.0",
"lodash.uniq": "^4.3.0",
"moment": "^2.14.1",
"normalizr": "^2.1.0",
"react": "15.0.2",
"react-native": "0.26.2",
"react-native-animatable": "^0.6.1",
"react-native-app-intro": "^1.0.2",
"react-native-billing": "^1.3.0",
"react-native-code-push": "^1.12.2-beta",
"react-native-code-push-saga": "^1.0.0",
"react-native-console-panel": "0.0.9",
"react-native-debug-stylesheet": "^0.1.1",
"react-native-drawer": "file:./custom_modules/react-native-drawer",
"react-native-extra-dimensions-android": "^0.17.0",
"react-native-fabric": "^0.2.3",
"react-native-fetch-blob": "^0.4.2",
"react-native-fs": "^1.4.0",
"react-native-gifted-spinner": "0.0.4",
"react-native-google-analytics-bridge": "^2.1.0",
"react-native-htmlview": "^0.5.0",
"react-native-i18n": "0.0.8",
"react-native-image-progress": "^0.5.0",
"react-native-in-app-utils": "^4.0.0",
"react-native-keyboard-aware-scroll-view": "^0.1.0",
"react-native-navbar": "^1.5.0",
"react-native-router-flux": "^3.30.0",
"react-native-search-bar": "^2.11.0",
"react-native-side-menu": "^0.19.0",
"react-native-simple-store": "^1.0.1",
"react-native-sound": "^0.8.3",
"react-native-sqlite-storage": "^2.1.6",
"react-native-swiper": "^1.4.4",
"react-native-vector-icons": "^2.0.2",
"react-redux": "^4.4.5",
"react-timer-mixin": "^0.13.3",
"redux": "^3.5.2",
"redux-form": "^6.0.0-alpha.15",
"redux-logger": "^2.6.1",
"redux-saga": "^0.10.4",
"redux-thunk": "^2.1.0",
"reselect": "^2.5.1",
"rn-viewpager": "^1.1.2",
"rnpm": "^1.7.0",
"tween-functions": "^1.2.0"
}
}
Can anyone help?
The issue happens because either your project (via a custom .babelrc) or one of your dependencies is relying on a es2015 preset that doesn't work with React Native. The reason for that is because it includes transform-typeof-symbol which calls babelHelpers.typeof that is not bundled with React Native.
If you have a custom babelrc - the solution is simple, just remove this preset.
Afterwards, restart packager w/o cache and you should be set.
Note: It maybe one of your dependencies that uses that preset - in such case, there's nothing you can do but try forking it and removing the preset yourself.
A part solution to this is using babel-preset-react-native-stage-0
https://www.npmjs.com/package/babel-preset-react-native-stage-0
There is a PR here to fix this in the react-native codebase: enter link description here
I work on an Ember CLI project that has Ember Data declared as a dependency in the the project's package.json and bower.json files respectively. Two different Ember Data versions are declared.
Which dependency takes precedence and why must it be declared in two places?
package.json
{
"devDependencies": {
"active-model-adapter": "1.13.5",
"emberx-select": "1.1.4",
"broccoli-asset-rev": "^2.0.2",
"broccoli-funnel": "^0.2.3",
"ember-cli": "0.2.7",
"ember-cli-app-version": "0.3.3",
"ember-cli-babel": "^5.0.0",
"ember-cli-content-security-policy": "0.4.0",
"ember-cli-dependency-checker": "^1.0.0",
"ember-cli-html5-validation": "0.0.18",
"ember-cli-htmlbars": "0.7.6",
"ember-cli-ic-ajax": "0.1.1",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-qunit": "0.3.13",
"ember-cli-rails-addon": "0.0.11",
"ember-cli-sass": "4.0.1",
"ember-cli-uglify": "^1.0.1",
"ember-data": "1.0.0-beta.18",
"ember-disable-proxy-controllers": "^1.0.0",
"ember-export-application-global": "^1.0.2",
"shared": "../shared"
}
}
bower.json
{
"dependencies": {
"ember": "1.13.2",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "ember-cli-test-loader#0.1.3",
"ember-data": "1.13.4",
"ember-load-initializers": "ember-cli/ember-load-initializers#0.1.4",
"ember-qunit": "0.3.3",
"ember-qunit-notifications": "0.0.7",
"ember-resolver": "~0.1.15",
"jquery": "^1.11.1",
"loader.js": "ember-cli/loader.js#3.2.0",
"qunit": "~1.17.1",
"bourbon": "~4.2.3",
"bitters": "~1.0.0",
"neat": "~1.7.2"
}
}
The dependency in Bower determines which version is used in the built app. I believe the npm package is just there for the development tooling.