I have downloaded this library (https://github.com/pokusew/nfc-pcsc) and now i'm trying to run an Electron project in it, but is giving me everytime problems when i try to run it as an Electron project.
So my question is: How can I implement this library on my Electron project and make it work not as node.js
I tried to npm install --save electron#latest in the library and change on the json the script "example": "node -r #babel/register examples/read-write.js" to "example": "electron -r #babel/register examples/read-write.js" also i have tried to uninstall and install, i have done electron-rebuild
"rebuild": "electron-rebuild -f -w yourmodule",
"build": "babel src --out-dir dist",
"example": "electron -r #babel/register examples/read-write.js",
"example-basic": "node -r #babel/register examples/basic.js",
"example-from-readme-3": "node -r #babel/register examples/from-readme-3.js",
"example-led": "node -r #babel/register examples/led.js",
"example-mifare-classic": "node -r #babel/register examples/mifare-classic.js",
"example-mifare-desfire": "node -r #babel/register examples/mifare-desfire.js",
"example-mifare-ultralight-ntag": "node -r #babel/register examples/mifare-ultralight-ntag.js",
"example-ndef": "node -r #babel/register examples/ndef.js",
"example-uid-logger": "node -r #babel/register examples/uid-logger.js",
"example-without-auto": "node -r #babel/register examples/without-auto.js",
"prepack": "yarn build && yarn test",
"test": "cross-env NODE_ENV=test ava test/tests.js --verbose"
}
I'm getting this error when i'm trying to run the app as Electron app (https://i.imgur.com/UhSjlo6.png) and when i do the rebuild i have this error: × Rebuild Failed An unhandled error occurred inside electron-rebuild
Electron as of v5.0.0 is using Node.js v12.0.0. This native module (nfc-pcsc) is not building correctly for that version.
Downgrade Electron to v4, rebuild via "electron-rebuild" and it should build properly.
npm install --save-dev electron#4
then
electron-rebuild
Related
I have two package.json files, one in my root directory, and one in my react-web directory...
heres the scripts:
root directory package.json
"start": "cd react-web && npm run postinstall && export REACT_APP_CUSTOMER_ENVIRONMENT=gianlucaherokutest320880 && npm start"
react-web directory package.json
"start": "node --max_old_space_size=4096 react-app-rewired start",
it gives me this error:
Error: Cannot find module '/app/react-web/react-app-rewired'
However, I have react-app-rewired installed, and I deleted node_modules and npm install again already! Does anyone have any ideas?
How to configure test setup with mocha to support es6 with babel 6?
I tried to configure with --require option with mocha as as mentioned here but it does not resolve my problem
I have also tried with --compiler option but it does not support with mocha v7
Node v13.13.0
Babel v6.26
mocha v7.1.1
> mocha './test/**/*.js' --require babel-core/register
import module from '../models/module';
^^^^^^
SyntaxError: Cannot use import statement outside a module
Module is a .js files
babelConfig.babelrc file contains
{
"presets": ["env"]
}
pakcage.json configrations of scripts section:
"scripts": {
"start": "nodemon server.js --exec babel-node --presets env",
"release": "npm run clean && npm run build && npm run serve",
"clean": "rm -rf dist && mkdir dist",
"build": "babel . -s -D -d dist --presets env --ignore node_modules",
"serve": "node dist/server.js",
"test": "mocha './test/**/*.js' --require babel-core/register"
}
I know it has been covered in different questions but mine is a bit different:
Sorry in advance if it sounds really noob.
this is the script in package.json:
"start": "nodemon ./index.js --exec \"node -r babel-register\"",
I replaced that with:
"start": "node scripts/start.js",
and in start.js, I do:
const { execSync } = require('child_process')
execSync('nodemon ../index.js --exec \"node -r babel-register\"')
which throws an error:
/bin/sh: nodemon: command not found
Am I right with "execSync"?
I tried import nodemon in the file but it is obviously not helping.
What you're doing should work if nodemon is installed globally, i.e. with:
npm install -g nodemon
But if it's installed as a project dependency, i.e. with:
npm install --save-dev nodemon
Then you'll need to run it from the directory containing all the locally installed binaries: node_modules/.bin/
So something like this should work:
execSync('./node_modules/.bin/nodemon ../index.js --exec \"node -r babel-register\"')
How to know in react app on client, does current env is prod or staging?
On Backend / node js we have process.env.STAGE_NAME
But that now work on client.
This is package.json.
How I get that info on Client?
"scripts": {
"postinstall": "cd ./localDb && sls dynamodb install && cd ../",
"buildServer": "tsc -b ./server/tsconfig.json",
"buildClient": "next build ./client",
"build": "npm run buildServer && npm run buildClient",
"build:dev": "npm run buildServer && NODE_ENV=development npm run buildClient",
"dev": "node --inspect server/build/index.js",
"start": "NODE_ENV=production node server/build/index.js",
"testClient": "nyc --reporter=html --reporter=text mocha --timeout 15000 --reporter mochawesome --exit",
"testServer": "nyc --reporter=html --reporter=text mocha --timeout 15000 --reporter mochawesome --exit server/build/tests/*.js",
"lintServer": "tslint 'server/**/*.ts' --quiet --project server/tsconfig.json",
"lintClient": "eslint '**/*.{js,jsx}' --quiet",
"lint": "npm run lintClient && npm run lintServer",
"format": "prettier --write '**/*.{js,jsx,css,scss,ts}'",
"test": "npm run testClient && NODE_ENV=testing npm run testServer",
"local:db": "cd ./localDb && sls dynamodb start && dynamodb-admin"
},
You can do this,
"scripts": {
"build": "npm run buildServer && npm run buildClient",
"build:dev": "npm run buildServer && NODE_ENV=development npm run buildClient",
"build:stage": "npm run buildServer && NODE_ENV=staging npm run buildClient",
},
Now you can know the environment from process.env.NODE_ENV.
If you have created the app using create-react-app I would recommend using .env file. Check the link for further read, Link
It depends on how did you run the react app and what did you define it in package.json
on depend on your package.json and NODE_ENV= parameter:
Start app for test env : npm test
Start app for prod env : npm start
I have a lerna repo. There is devDependency to concurrently package from my root package.json. When I type "lerna bootstrap" to command line, it works properly and install all root and subPackages` dependencies to root node_modules folder. But when i type "npm start" it says: 'concurrently' is not recognized as an internal or external command. When i check node_modules/concurrently folder it exists without problem.
My start script is concurrently --kill-others "npm run start-client" "npm run start-server".
This situation same with webpack-dev-server. How can i fix this problem except reinstalling everything.
package.json:
{
"name": "x-workspace",
"private": true,
"workspaces": [
"packages/*"
],
"devDependencies": {
"concurrently": "3.5.0",
"lerna": "^2.11.0"
},
"scripts": {
"start": "concurrently --kill-others \"npm run start-client\" \"npm run start-server\"",
"build": "webpack --hot",
"start-client": "npm --prefix ./packages/client-app start",
"start-server": "cd ./packages/server-app && dotnet run",
"clean": "rimraf node_modules package-lock.json ./packages/client-app/package-lock.json"
}
}
I found problem. There is no .bin folder in root node_modules folder. This is result of updating yarn to 1.8.0. When i return back to yarn 1.6.0, it works perfectly.
Thanks to David R. and other users.
I believe you don't have the concurrently package installed globally, To confirm try executing the below command and check if it returns anything,
npm list -g concurrently
If you've received an --(empty) response, then you'll have to install it globally.
npm install -g concurrently
Hope this helps!.