So I am getting the error "Cannot find module jquery" in my Electron application. In my index.ejs file I have the code:
window.jQuery = window.$ = require('jquery');
Inside of a script tag.
You need to add jquery as a dependency to your app/package.json.
Change directory to app and run
npm i jquery --save
or if you are using yarn
yarn add jquery
It should look something like this afterwards.
{
"name": "vueelectron",
"version": "0.0.0",
"description": "An electron-vue project",
"main": "./dist/main.js",
"dependencies": {
"babel-runtime": "^6.23.0",
"bootstrap": "^3.3.7",
"jquery": "^3.2.1",
"vue": "^2.1.10",
"vue-electron": "^1.0.6",
"vue-resource": "^1.0.3",
"vue-router": "^2.1.2",
"vuex": "^2.3.1"
},
"devDependencies": {},
"author": ""
}
Related
I am working on a register user setup in React JS, installed crypto library from to secure passwords but when I run the program , it gives me an error :
ERROR in ./node_modules/jwa/index.js 5:13-30
Module not found: Error: Can't resolve 'crypto' in 'E:\Node
Tutorial\registerSetup\client\node_modules\jwa'
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 }
Here is my package.json file :
{
"name": "registerSetup",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "NODE_ENV= production node server",
"dev": "nodemon server"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.1",
"cors": "^2.8.5",
"crypto": "^1.0.1",
"crypto-browserify": "^3.12.0",
"dotenv": "^15.0.0",
"express": "^4.17.2",
"express-jwt": "^6.1.0",
"express-validator": "^6.14.0",
"google-auth-library": "^7.11.0",
"jsonwebtoken": "^8.5.1",
"loadash": "^1.0.0",
"lodash": "^4.17.21",
"mongoose": "^6.1.8",
"morgan": "^1.10.0",
"node-fetch": "^3.2.0",
"nodemailer": "^6.7.2",
"nodemon": "^2.0.15"
}
}
The package.json for my react folder in registerSetup --> https://pastebin.com/hqBs7J4s
I think you should go to your node_modules/react-scripts/config/webpack.config.json and there write the following code in resolve block
fallback: {
"crypto": require.resolve("crypto-browserify")
}
Note: crypto-browserify should be installed
Crypto is a built-in Node module you don't have to install it. Uninstall "crypto": "^1.0.1" and then try:
const crypto = require("crypto")
You can try to downgrade the react-scripts in package.json version to : 4.0.3
i am developing an app with node js , it works perfectly locally but crashes anytime i try to upload it to heroku,it says Error: Cannot find module 'dotenv.i have installed it serval times and also updated my package but the problem continues,
this is my package.json
{
"name": "myapp",
"description": "a really cool app",
"version": "1.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"engines": {
"node": "10.16.3",
"npm": "6.13.4"
},
"dependencies": {
"#mapbox/mapbox-sdk": "^0.9.0",
"body-parser": "^1.19.0",
"cookie-parser": "~1.4.4",
"debug": "~4.1.1",
"ejs": "~3.0.1",
"ejs-mate": "^3.0.0",
"express": "^4.17.1",
"express-session": "^1.17.0",
"faker": "^4.1.0",
"http-errors": "~1.7.3",
"method-override": "^3.0.0",
"mongoose": "^5.8.1",
"mongoose-paginate": "^5.0.3",
"morgan": "~1.9.1",
"passport": "^0.4.1",
"passport-local": "^1.0.0",
"passport-local-mongoose": "^5.0.1",
"serve-favicon": "^2.5.0"
},
"devDependencies": {
"dotenv": "^8.2.0",
"locus": "^2.0.4"
}
}
this is my Procfile
web: node app.js
this is my git ignore file
/node_modules
.DS_Store
/*.env
Try movin dotenv from 'devDependencies' to 'dependencies'
Anything that is needed to actually run your app (lets call it "in production"), should be in 'dependencies'.
Anything that you may need while eg testing can be installed to 'devDependencies'
My react app (that I think is based of create-react-app - I didn't create it initially)
Doesn't use an index.html, it has an index.js, well it has a few index.js,
I want to know how this works? Basically when I run npm run build, a build folder isnt created, an es and a lib folder are created which are copies of the src folder (which contains the components)
Why are these two folders created and not a build?
I used an npm package: https://www.npmjs.com/package/react-chat-window
Here is my package.json (might hold the clues):
I really want to understand because on my server, I am using nginx, but it isnt routed to any of the files, the sites-available/default doesnt route to anywhere its the default settings so how does it work!?
{
"name": "react-chat-window",
"version": "1.0.8",
"description": "react-live-chat React component",
"main": "lib/index.js",
"module": "es/index.js",
"files": [
"css",
"es",
"lib",
"umd"
],
"scripts": {
"build": "nwb build-react-component --copy-files",
"clean": "nwb clean-module && nwb clean-demo",
"start": " nwb serve-react-demo",
"gh:publish": "nwb build-demo && gh-pages -d demo/dist"
},
"dependencies": {
"#material-ui/core": "^3.2.0",
"emoji-js": "3.2.2",
"fs": "0.0.1-security",
"gh-pages": "^1.0.0",
"material-ui": "^0.20.2",
"moment": "^2.24.0",
"prop-types": "15.5.10",
"react-highlight.js": "1.0.5",
"react-slick": "^0.23.2",
"slick-carousel": "^1.8.1",
"socket.io-client": "2.0.3"
},
"peerDependencies": {
"react": "16.6.0",
"react-dom": "^16.6.0"
},
"devDependencies": {
"nwb": "0.17.x",
"react": "^16.6.0",
"react-dom": "^16.6.0"
},
"author": "",
"homepage": "",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/kingofthestack/react-live-chat.git"
},
"keywords": [
"react-component"
]
}
you are not using create-react-app , you're using another boilerplate called nwb , here is his official documentation to understand how it works https://github.com/insin/nwb and here is his documentation concerning react
https://github.com/insin/nwb/blob/master/docs/guides/ReactApps.md#developing-react-apps-with-nwb
I'm new here, I hope I enter all the information needed.
When trying to do some webscraping in my app, I got errors
module...does not exist in the haste module map" with 'events' and 'stream'.
I researched my issue, and tried the directions at: https://github.com/facebook/react-native/issues/4968 except for the watchman step, since I am on Windows.
Unfortunately, the same error keeps popping up, just with different modules. This time its babel that's complaining.
What should I do?
I also tried making a new react-native-init project and just git cloning my src code. Still get a similar error.
{
"name": "Work",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"axios": "^0.18.0",
"cheerio": "^1.0.0-rc.2",
"events": "^3.0.0",
"firebase": "^5.0.3",
"htmlparser2": "^3.9.2",
"react": "16.3.1",
"react-native": "0.55.2",
"react-native-calendars": "^1.21.0",
"react-native-communications": "^2.2.1",
"react-native-fs": "^2.11.17",
"react-native-router-flux": "^4.0.0-beta.28",
"react-native-vector-icons": "^5.0.0",
"react-navigation": "^2.13.0",
"react-twitter-embedded-timeline": "^0.5.0",
"react-twitter-widgets": "^1.7.1"
},
"devDependencies": {
"babel-jest": "22.4.3",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.3",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}
Copied from node cmd screen.
I faced the same issue with my react-native app.
resetting the node cache solved the issue for me :
npm start -- --reset-cache
I hope it helps
I am developing a WebGL library that I would like to import into an EmberJS project as a dependency. Unless I'm mistaken, I believe that I can do this via the repository directly without having to make an npm package but I am having trouble getting it to work.
I have made a watered down library and ember project in a couple repos here and here respectively to demonstrate my problem.
If you clone the library and run npm run build it'll make a test bundle which can be called by the test html file packageTest.html. It should print out 'Hello World Test Member is: 5'.
In the Ember project I have a component in which I would like to import the 'HelloWorld' class from the library and call one of its member methods.
import Ember from 'ember';
//import HelloWorld from 'npm-package-test';
export default Ember.Component.extend({
isWide: false,
actions: {
toggleImageSize() {
// var h = new HelloWorld();
// console.log(h.print());
this.toggleProperty('isWide');
}
}
});
When I uncomment the import statement I get the console error
Error: Could not find module 'npm-package-test'
I'm still pretty new to npm packaging and how dependencies work (and know next to nothing about Ember) but from my limited understanding I feel like this method should work the way I currently have it.
For the library, I have the source files being babeled into ES5 in its lib folder. As you can see in the package.json for the library below I have the main set to the index file in the lib folder so that the Ember project can pull the babeled modules.
Library: package.json
{
"name": "npm-package-test",
"version": "1.0.0",
"description": "JibJab Render Library for eCards",
"main": "lib/index.js",
"scripts": {
"prepublishOnly": "npm run build",
"build-test": "browserify test.js > demo/testbundle.js",
"build": "babel ./src -d ./lib && npm run build-test",
"lint": "eslint ./src",
"test": "nyc mocha --require babel-core/register"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nhoughto5/NPM_PackageTest.git"
},
"author": "JibJab",
"license": "ISC",
"bugs": {
"url": "https://github.com/nhoughto5/NPM_PackageTest/issues"
},
"homepage": "https://github.com/nhoughto5/NPM_PackageTeste#readme",
"devDependencies": {
"babel-cli": "6.26.0",
"babel-preset-env": "1.6.1",
"eslint": "4.19.0",
"mocha": "5.0.4",
"nyc": "11.6.0"
},
"nyc": {
"reporter": [
"lcov",
"text"
]
},
"dependencies": {
"domready": "^1.0.8"
}
}
For reference, here is the lib/index.js which should be the entry point of my library:
Library: lib/index.js
'use strict';
module.exports = {
TestClass: require('./TestClass'),
HelloWorld: require('./HelloWorld')
};
In the ember project I have the library repository listed as a dependency:
Ember: package.json
{
"name": "test-ember-app",
"version": "0.0.0",
"description": "Small description for test-ember-app goes here",
"license": "MIT",
"author": "",
"directories": {
"doc": "doc",
"test": "tests"
},
"repository": "",
"scripts": {
"build": "ember build",
"start": "ember server",
"test": "ember test"
},
"devDependencies": {
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^3.0.0",
"ember-browserify": "1.2.1",
"ember-cli": "2.13.1",
"ember-cli-app-version": "^3.0.0",
"ember-cli-babel": "^6.0.0",
"ember-cli-dependency-checker": "^1.3.0",
"ember-cli-eslint": "^3.0.0",
"ember-cli-htmlbars": "^1.1.1",
"ember-cli-htmlbars-inline-precompile": "^0.4.0",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-mirage": "0.4.3",
"ember-cli-qunit": "^4.0.0",
"ember-cli-shims": "^1.1.0",
"ember-cli-sri": "^2.1.0",
"ember-cli-tutorial-style": "2.0.0",
"ember-cli-uglify": "^1.2.0",
"ember-data": "^2.13.0",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.0.0",
"ember-resolver": "^4.0.0",
"ember-source": "~2.13.0",
"ember-welcome-page": "^3.0.0",
"loader.js": "^4.2.3"
},
"engines": {
"node": ">= 4"
},
"private": true,
"dependencies": {
"npm-package-test": "git+https://github.com/nhoughto5/NPM_PackageTest.git"
}
}
When I run npm install in the ember project I can see that the folder structure from the library appears in the node_modules folder. To my limited experience, everything seems correct but for some reason I am still getting this undefined module error.
Is there a step I've missed or some crucial detail I'm missing?
Yes, there’s one step you are still missing. For Ember-CLI to understand that you want to include your npm package in your app’s vendor files, you’ll need to use app.import as outlined here: https://guides.emberjs.com/v3.0.0/addons-and-dependencies/managing-dependencies/
That approach with app.import has existed since Ember-CLI 2.15, but if you are on an older version you’ll need to upgrade first.