When I run my Node.js application I always get Error: Can't resolve 'fs'.
I looked into some questions and tried to change the dependencies in my package.json file.
"dependencies": {
"#types/vexflow": "^3.0.0",
"fs": "^0.0.1-security",
"jszip": "3.7.1",
"loglevel": "^1.6.8",
"socket.io": "^4.2.0",
"typescript-collections": "^1.3.3",
"vexflow": "1.2.93"
},
Is there something else I need to do?
Thanks
Related
I have looked through and tried all of the existing solutions on Stack Overflow. I have:
changed my node version
installed rails:webpacker over and over
deleted node_modules and public/packs folder
ran yarn install, bundle
but I keep getting this error:
Webpacker::Manifest::MissingEntryError
Webpacker can't find hello_react in .../public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}
The line giving an error:
<%= javascript_pack_tag 'hello_react' %>
My versions:
node: v16.14.2
Rails 6.0.6
my package.json:
{
"name": "appname",
"private": true,
"dependencies": {
"#babel/preset-react": "^7.18.6",
"#rails/actioncable": "^6.0.0",
"#rails/activestorage": "^6.0.0",
"#rails/ujs": "^6.0.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"turbolinks": "^5.2.0",
"webpack": "4.46.0"
},
"version": "0.1.0",
"devDependencies": {
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.1"
}
}
I cannot move past this error, what am I missing?
I have a nodejs app created through the Vue CLI. I need to use the aws4 node module to sign my requests. However, when I use the aws4 module the app fails to serve due to the following error:
ERROR in ./node_modules/aws4/aws4.js 4:13-30
Module not found: Error: Can't resolve 'crypto' in 'C:\Users\henry\Repos\AWS4 TEST\aws4-test\node_modules\aws4'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
- install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "crypto": false }
I got this error for the 3 imports in the aws module: crypto, url and querystring.
I read the error message and saw that the version of webpack the vue cli uses is 5+ so the core modules such as crypto are not included anymore.
(I've never really used webpack before, but the instructions seems simple.)
I created a new file in my project webpack.config.js and added the following:
module.exports = {
resolve: {
fallback: {
crypto: require.resolve('crypto-browserify'),
},
},
};
I then installed the crypto-browserify package.
I still get the error, it's make 0 difference.
I've looked online and have tried solutions suggested for the crypto not found issue. None of them seem to work either. I've tried:
Adding this to the package.json
"browser": {
"crypto": false
}
Adding the crypto object to the paths object in tsconfig.json
"compilerOptions": {
"baseUrl": "./",
"paths": {
"crypto": ["node_modules/crypto-browerify"],
}
I tried using the node module: node-polyfill-webpack-plugin. Which did resolve the issue for url and querystring (as soon as the module was imported). But the issue with crypto remains.
Here is my package.json
{
"name": "aws4-test",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint"
},
"dependencies": {
"aws4": "^1.11.0",
"axios": "^0.27.2",
"core-js": "^3.8.3",
"crypto-browserify": "^3.12.0",
"crypto-js": "^4.1.1",
"node-polyfill-webpack-plugin": "^2.0.0",
"vue": "^2.6.14",
"vue-class-component": "^7.2.3",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.5.1",
"vuex": "^3.6.2"
},
"devDependencies": {
"#types/aws4": "^1.11.2",
"#types/jest": "^27.0.1",
"#typescript-eslint/eslint-plugin": "^5.4.0",
"#typescript-eslint/parser": "^5.4.0",
"#vue/cli-plugin-babel": "~5.0.0",
"#vue/cli-plugin-eslint": "~5.0.0",
"#vue/cli-plugin-router": "~5.0.0",
"#vue/cli-plugin-typescript": "~5.0.0",
"#vue/cli-plugin-unit-jest": "~5.0.0",
"#vue/cli-plugin-vuex": "~5.0.0",
"#vue/cli-service": "~5.0.0",
"#vue/eslint-config-airbnb": "^6.0.0",
"#vue/eslint-config-typescript": "^9.1.0",
"#vue/test-utils": "^1.1.3",
"#vue/vue2-jest": "^27.0.0-alpha.2",
"babel-jest": "^27.0.6",
"eslint": "^7.32.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-vue": "^8.0.3",
"eslint-plugin-vuejs-accessibility": "^1.1.0",
"jest": "^27.0.5",
"ts-jest": "^27.0.4",
"typescript": "~4.5.5",
"vue-template-compiler": "^2.6.14"
},
"browser": {
"crypto": false
}
}
To isolate the issue I created a new vue 2 app though the cli then just added the aws4 and axios modules. The fact that the node-polyfill-webpack-plugin works to resolve the errors for all but crypto error seems odd. Perhaps something else is overwritting that.
Thanks for your help.
The reason the webpack config wasn't working was because I am using the vue-cli-service. So to configure the webpack config I needed to edit the vue.config.js file and use the configureWebpack object. Docs here: https://cli.vuejs.org/guide/webpack.html
I'm trying to run tests with jest on a basic mongodb set-up with express. following the instructions in the jestjs.io documentation. When I run may package.json script: "test": "jest" I get the following error:
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (node_modules/#shelf/jest-mongodb/environment.js:20:49)
The line in environment.js referenced above is:
module.exports = class MongoEnvironment extends TestEnvironment {
So the TestEnvironmentclass is undefined. Judging from other stack discussions it looks like there's some circular reference issue. Possibly to be solved by changing the order of how the modules are run, but I don't know how to do this?
I've tried changing my version of node, and I've also tried deleting my node_modules and reinstalling. When I run yarn check it tells me all my packages are in sync.
package.json:
...
"dependencies": {
"dotenv": "^16.0.1",
"express": "^4.18.1",
"mongodb": "^4.6.0"
},
"devDependencies": {
"#babel/core": "^7.18.2",
"#babel/preset-env": "^7.18.2",
"#babel/preset-typescript": "^7.17.12",
"#shelf/jest-mongodb": "^3.0.0",
"#types/express": "^4.17.13",
"#types/jest": "^27.5.1",
"#types/mongodb": "^4.0.7",
"#types/node": "^17.0.36",
"jest": "^28.1.0",
"jest-environment-node": "^27.0.0",
"ts-jest": "^28.0.3",
"ts-node-dev": "^2.0.0",
"typescript": "^4.7.2"
},
...
I was able to solve it from:
const NodeEnvironment = require('jest-environment-node')
to:
const NodeEnvironment = require('jest-environment-node').default
I got rid of this error by updating:
"jest-environment-node": "^27.0.0",
to
"jest-environment-node": "^28.1.0",
I'm getting the following error anytime I try to run 'npm run production'. The rest of the error is just a list of 'node_modules' packages where this error also occur.
ERROR in ./resources/assets/sass/app.scss
Module build failed: ModuleBuildError: Module build failed: TypeError: Cannot read property 'unprefixed' of undefined at clearDecl (/Users/prusso/Sites/qut-match-my-skills/node_modules/postcss-unprefix/lib/clearDecl.js:13:30)
I believe the error is in the version of 'autoprefixer' and/or 'postcss-unprefix'. Please check my 'devDependencies' below:
"devDependencies": {
"autoprefixer": "^8.6.3",
"babel-eslint": "^8.2.6",
"babel-polyfill": "^6.26.0",
"browser-sync": "^2.24.5",
"browser-sync-webpack-plugin": "2.0.1",
"cross-env": "^5.2.0",
"cssnano": "^3.10.0",
"eslint": "^4.0.0",
"eslint-plugin-vue": "^4.7.1",
"laravel-mix": "^2.1.11",
"postcss-unprefix": "^2.1.3",
"prettier-eslint": "^8.8.2",
"raw-loader": "^0.5.1"
},
"dependencies": {
"#nextindex/next-scss": "^1.2.1",
"animate-sass": "^0.8.2",
"axios": "^0.18.0",
"babel-core": "^6.26.3",
"es6-promise": "^4.2.4",
"family.scss": "^1.0.8",
"lodash.compact": "^3.0.1",
"lodash.get": "^4.4.2",
"normalize.css": "^8.0.0",
"portal-vue": "^1.3.0",
"smoothscroll-polyfill": "^0.4.3",
"uuid": "^3.3.2",
"vue": "^2.5.16",
"vue-parallaxy": "^1.1.1",
"vue-router": "^3.0.1",
"vuex": "^3.0.1",
"vuex-persistedstate": "^2.5.4",
"zeus-grid": "^8.2.0"
}
Other thing that I have noticed is that if I comment out the following line 'require('postcss-unprefix')' inside 'webpack.mix.js' and run 'npm run production' everything works fine.
mix.options({
postCss: [
// require('postcss-unprefix'),
require('autoprefixer')({
browsers: '>0.1%',
}),
require('cssnano')({
preset: [
'default',
{
discardComments: {
removeAll: true,
},
},
],
}),
],
});
Thanks for your help!!
try autoprefixer:10.2.5 latest version
Trt postcss-rtlcss package insted of postcss-rtl
Latest version (postcss#^8.0.0)
npm install postcss-rtlcss --save-dev
Latest legacy version (postcss#^7.0.0)
npm install postcss-rtlcss#legacy --save-dev
I updated React-Native from 0.14.0 to 0.16.0 and from now, I have errors at runtime:
Here are the npm dependencies:
"dependencies": {
"async": "^1.5.0",
"immutable": "^3.7.6",
"react-native": "^0.16.0",
"react-native-contacts": "../../react-native-contacts",
"react-native-contacts-rx": "^1.0.1",
"react-native-gifted-messenger": "0.0.7",
"react-native-i18n": "0.0.6",
"react-redux": "^4.0.1",
"redux": "^3.0.5",
"rx": "^4.0.7"
},
"devDependencies": {
"babel-eslint": "^5.0.0-beta6",
"eslint": "^1.10.3",
"eslint-config-airbnb": "^2.1.1",
"eslint-plugin-react": "^3.11.3",
"events": "^1.1.0",
"flux": "^2.1.1",
"keymirror": "^0.1.1",
"lodash": "^3.10.1",
"redux-devtools": "^3.0.0"
}
And my .babelrc file:
{
"retainLines": true,
"compact": true,
"comments": false,
}
Any suggestions?
The Questions was answered in an issue #Jean Lebrument submitted. Positing answer here for stumblers like myself...
https://github.com/facebook/react-native/issues/4844
The problem is most likely in your .babelrc file. If you experience this problem, compare your .babelrc file to react natives default one. Try removing the file or building off of default one, adding the features that you need.
Make sure to restart your packager, stop, and re-run your project.
I had this exact same problem you can check out what I did here - https://stackoverflow.com/a/53069785/2884655
But in short I just imported the babel-plugin-transform-async-to-generator module into my project and added it into my babelrc file