Can we run unit test class on LWC in Windows? - salesforce

I am a beginner in Lightning Web Component(LWC) unit test. I am facing problems in testing my LWC component using lwc-jest Node.js dependency. I am kind of having a hard time in sourceApiVersion configuration. When I run the test is says
PS C:\Users\rdesai\Documents\GitHub\nimbusdevv> npm run test:unit
> nimbusdevv#1.0.0 test:unit C:\Users\rdesai\Documents\GitHub\nimbusdevv
> lwc-jest
error Invalid sourceApiVersion found in sfdx-project.json. Expected 47.0, found 45.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nimbusdevv#1.0.0 test:unit: `lwc-jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nimbusdevv#1.0.0 test:unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\rdesai\AppData\Roaming\npm-cache\_logs\2019-11-21T19_21_35_974Z-debug.log
But when I check my current status of my salesforcedx, usingsfdx plugins --core it shows the API version as 47
PS C:\Users\rdesai\Documents\GitHub\nimbusdevv> sfdx plugins --core
#oclif/plugin-commands 1.2.3 (core)
#oclif/plugin-help 2.2.1 (core)
#oclif/plugin-not-found 1.2.3 (core)
#oclif/plugin-plugins 1.7.8 (core)
#oclif/plugin-update 1.3.9 (core)
#oclif/plugin-warn-if-update-available 1.7.0 (core)
#oclif/plugin-which 1.0.3 (core)
#salesforce/sfdx-trust 3.0.5 (core)
analytics 1.2.1 (core)
generator 1.1.1 (core)
salesforcedx 47.6.2 (core)
├─ salesforcedx-templates 47.6.2 (core)
└─ salesforce-alm 47.9.0 (core)
sfdx-cli 7.33.2 (core)
Hope someone can help me understand where I am going wrong.

Check your sfdx-project.json file which is located in your project root and change the API version from 45.0 to 47.0 inside the file.

Related

dependencies are incompatible with the installed expo package version ,Cannot find module 'nocache'

I really hope some of you can help me.
So I did some upgrates at one of my old app (which it is already on the store), and then when I tried to upload the apk it said I needed an API 30 (mine was 29). So I tried to upgrade the SDK and expo. Since that moment everything doesen't work.
Here sending the errors I have:
expo start ..
Some dependencies are incompatible with the installed expo package version:
- expo-ads-admob - expected version: ~10.0.4 - actual version installed: 8.3.0
- expo-font - expected version: ~9.1.0 - actual version installed: 8.3.0
- expo-updates - expected version: ~0.5.4 - actual version installed: 0.3.5
- react-native-gesture-handler - expected version: ~1.10.2 - actual version installed: 1.7.0
- react-native-reanimated - expected version: ~2.1.0 - actual version installed: 1.13.4
- react-native-safe-area-context - expected version: 3.2.0 - actual version installed: 3.1.4
- react-native-screens - expected version: ~3.0.0 - actual version installed: 2.10.1
- react-native-unimodules - expected version: ~0.13.3 - actual version installed: 0.12.0
Your project may not work correctly until you install the correct versions of the packages.
To install the correct versions of these packages, please run: expo doctor --fix-dependencies,
or install individual packages by running expo install [package-name ...]
Cannot find module 'nocache'
Require stack:
- C:\Users\gameZone\node_modules\#react-native-community\cli-server-api\build\index.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\dev-server\build\metro\importMetroFromProject.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\dev-server\build\HermesBundler.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\dev-server\build\MetroDevServer.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\build\start\startDevServerAsync.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\build\internal.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\build\index.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\build\exp.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\bin\expo.js
Error: Cannot find module 'nocache'
Require stack:
- C:\Users\gameZone\node_modules\#react-native-community\cli-server-api\build\index.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\dev-server\build\metro\importMetroFromProject.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\dev-server\build\HermesBundler.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\dev-server\build\MetroDevServer.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\build\start\startDevServerAsync.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\build\internal.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\build\index.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\build\exp.js
- C:\Users\AppData\Roaming\npm\node_modules\expo-cli\bin\expo.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at _nocache (C:\Users\gameZone\node_modules\#react-native-community\cli-server-api\build\index.js:105:39)
at createDevServerMiddleware (C:\Users\gameZone\node_modules\#react-native-community\cli-server-api\build\index.js:164:47)
at createDevServerMiddleware (C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\dev-server\src\middleware\devServerMiddleware.ts:54:7)
at runMetroDevServerAsync (C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\dev-server\src\MetroDevServer.ts:96:32)
at startDevServerAsync (C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\src\start\startDevServerAsync.ts:77:49)
at startAsync (C:\Users\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\src\start\startAsync.ts:69:41)
and when I try "expo doctor --fix-dependencies", this is what happens:
Unable to reach Expo servers. Falling back to using the cached dependency map (bundledNativeModules.json) from the package "expo" installed in your project.
Installing 8 SDK 41.0.0 compatible native modules using npm.
> npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: react-native-screens#3.0.0
npm ERR! node_modules/react-native-screens
npm ERR! react-native-screens#"~3.0.0" from the root project
npm ERR! peer react-native-screens#">= 2.0.0-alpha.0 || >= 2.0.0-beta.0 || >= 2.0.0" from #react-navigation/stack#5.14.9
npm ERR! node_modules/#react-navigation/stack
npm ERR! #react-navigation/stack#"^5.9.2" from the root project
npm ERR! 1 more (#react-navigation/drawer)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native-screens#"^1.0.0 || ^1.0.0-alpha" from react-navigation-drawer#1.4.0
npm ERR! node_modules/react-navigation-drawer
npm ERR! react-navigation-drawer#"^1.4.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
I also tried "npm install" and "yarn install" and to upgrade manually some of the depandencies of the list, for example "react-native-screen" or "react-font". But same errors.
You can try to delete your package.lock.json then rerun the command
expo doctor --fix-dependencies
There are two ways to solve this issue
Updating expo and running expo update to set the dependencies to something compatible with my SDK seemed to solve the issue for me
npm install -g expo-cli
expo update

Receive error when deploy to GitHub pages

I'm deploy react app to git hub pages and receive error. File sizes after gzip:
68.67 KB build\static\js\2.c2c334ae.chunk.js
2.98 KB build\static\js\main.8a72b1a2.chunk.js
774 B build\static\js\runtime~main.8f8a00a4.js
The project was built assuming it is hosted at /sort-customers-list/.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
To publish it at https://sejob.github.io/sort-customers-list,
run: npm run deploy
Find out more about deployment here:
sort-customers-list#0.1.0 deploy
C:\Users\SeJo\Documents\Code\DEV_HW\sort-customers-list
gh-pages -d build
The "file" argument must be of type string. Received type undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sort-customers-list#0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sort-customers-list#0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!
C:\Users\SeJo\AppData\Roaming\npm-cache\_logs\2019-08-01T12_09_52_445Z-debug.log
The problem occurs in the new version of GitHub pages. Just use this command to install the previous version of GitHub pages:
npm install gh-pages#2.0.1
Hope it will help!
I also had this same problem on a fresh install of create-react-app. I have no idea what the problem was, but I did the following:
Downgrade gh-pages from 2.1.0 to 2.0.1
Instead of running npm run deploy, manually run npm run build then gh-pages -d build from the commandline.
At first, I'd get the same error in the commandline, even after checking that the version was downgraded to 2.0.1, but for some reason it worked after manually creating the gh-pages branch and pushing some files into it. As of now, npm run deploy throws the error but at least gh-pages -d build from the console works.
INSTALL/REINSTALL GIT
Update NPM
Reopen EDITOR
this solved my problem
use version 2.0.1
npm i gh-pages#2.0.1

Cannot deploy with npm run Deploy in React on github pages

unfortunately I cannot deploy on GitHub my Color-recognition App in React JS on GitHub pages. I am using Webpack as bundler.
My system configuration is:
Webpack
Environment:
OS: Windows 10
Node: 8.12.0
Yarn: Not Found
npm: 6.4.1
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found
Packages: (wanted => installed)
react: ^16.5.2 => 16.5.2
react-dom: ^16.5.2 => 16.5.2
react-scripts: 1.1.5 => 1.1.5
I use extra added dependencies of Clarifai and Gsap and used the following steps:
I created on my Github account the repository Color-recognition without md file, and within added gh-pages branch, and in setting of repository under Source added gh-pages branch.
git add .
git commit -m "Uploading files"
git push -f origin master:gh-pages
git remote add origin
https://github.com/Geeeva/Color-recognition.git npm run deploy
The page should be deployed but it couldn't, with the error below. I wanted to put the project demo that is visible.
Tried the same procedure with the master branch of the Color-recognition, and I got the same error.
The error is following:
Cannot read property 'email' of null
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! color-recognition-depl#0.1.0 deploy: gh-pages -d build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the color-recognition-depl#0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional log ging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ivana\AppData\Roaming\npm-cache_logs\2018-09-19T19_58_34_ 829Z-debug.log
Link to my Github repo is: https://github.com/Geeeva/Color-recognition
I managed to fix it by setting my git config user name and email. (As
the link provided above specifies the need of both).
So just write in the terminal:
git config --global user.name your name
git config --global user.email #youremail
source: https://www.reddit.com/r/reactjs/comments/9hlin1/unable_to_deploy_react_app_to_github_pages/

create-react-app npm run build fail to minify watson node sdk

I am new to React and I am trying to build a react app using create-react-app and Watson node-sdk. Everything works fine in development mode after running npm start. But when I try to build a production package using npm run build and below is the error I receive.
e:\Microsoft\Workspace\React\myapp>npm run build
> myapp#0.1.0 build e:\Microsoft\Workspace\React\myapp
> react-scripts build
Creating an optimized production build...
Failed to compile.
Failed to minify the code from this file:
./node_modules/watson-developer-cloud/lib/helper.js:31
Read more here: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myapp#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional
logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\yk\AppData\Roaming\npm-cache\_logs\2017-09-
20T09_40_36_144Z-debug.log
The line that giving error is let missing; and seems like the let is causing the issue. Is there anything I can do with this?
Encountered this problem today. the doc suggests some solutions:
Open an issue on the dependency's issue tracker and ask that the package be published pre-compiled.
Fork the package and publish a corrected version yourself.
If the dependency is small enough, copy it to your src/ folder and treat it as application code.
Read more here: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify

IBM MFP cli install failure: npm install -g mfpdev-cli

When I attempt to install the IBM Mobile First CLI (mfpdev-cli), I'm getting an error.
Command:
npm install -g mfpdev-cli
Error details:
npm ERR! path /Users/timothy/dev/project/mdo-windows-support/package.json
npm ERR! code ENOPACKAGEJSON
...
npm ERR! package.json npm can't find a package.json file in your current directory.
It looks like it's trying to create an npm named 'mdo-windows-support' locally, but it fails. Any suggestions?
npm version: 5.0.1
node version: v8.0.0
Okay, it turns out that the versions of npm/node were the culprit. I switched back to the LTS version of Node, and it worked.

Resources