How to solve npm errors like below in react - npm-start

I'm new at react.js. Currently i'm trying to explore about react.js but after install creact-react-app using npm or yarn .Then wrote npm start but Still facing Invalid options object and npm ERR! code ELIFECYCLE too .
$ npm start
> random-users#0.1.0 start C:\Users\0x702!\Desktop\Today\New folder\random-users
> react-scripts start
Invalid options object. React Refresh Plugin has been initialized using an options object that does not match the API schema.
- options.overlay.module: The provided value "C:\\Users\\0x702!\\Desktop\\Today\\New folder\\random-users\\node_modules\\react-dev-utils\\refreshOverlayInterop.js" contains exclamation mark (!) which is not allowed because it's reserved for loader syntax.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! random-users#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the random-users#0.1.0 start 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\0x702!\AppData\Roaming\npm-cache\_logs\2021-01-14T15_40_45_603Z-debug.log
When i wrote yarn start the program shows me an error like below:
$ yarn start
yarn run v1.22.5
$ react-scripts start
Invalid options object. React Refresh Plugin has been initialized using an options object that does not match
the API schema.
- options.overlay.module: The provided value "C:\\Users\\0x702!\\Desktop\\Today\\New folder\\random-users\\n
ode_modules\\react-dev-utils\\refreshOverlayInterop.js" contains exclamation mark (!) which is not allowed be
cause it's reserved for loader syntax.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
package.json file
{
"name": "random-users",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.11.4",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
**Please guy's help me. I'm tried to solve this problem . **

First of all, its time to learn how to read errors ;)
Path contains exclamation mark, which is for loader syntax and cannot be used in that way.
Just rename C:\Users\0x702! folder to 0x702 or create another user to solve your problem :)

Related

AWS CodePipeline execute failed in deploying Nodejs app in Elastic Beanstalk

I know its a repetitive question but I didn't see any solution out there.
I deployed Nodejs app in Elastic Beanstalk through AWS CodePipeline. It was running perfect but after AWS announces a newer version of Linux OS, it's health became degraded and the deployment after this will also fail by CodePipeline.
So I decided to upgrade the Linux version but after that, the problem is didn't resolve and it shows me this error.
I checked eb-engine.log and I came to know that one of the nodejs package is didn't install by NPM.
2022/02/06 10:24:24.575676 [ERROR] An error occurred during execution
of command [app-deploy] - [Use NPM to install dependencies]. Stop
running the command. Error: Command /bin/sh -c npm --production
install failed with error exit status 1. Stderr:sharp: Installation
error: EACCES: permission denied, mkdir '/root/.npm/_libvips' npm WARN
newbackend#1.0.0 No description npm WARN newbackend#1.0.0 No
repository field.
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! sharp#0.30.0
install: (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy) npm ERR! Exit status 1 npm ERR! npm ERR!
Failed at the sharp#0.30.0 install 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!
/root/.npm/_logs/2022-02-06T10_24_24_562Z-debug.log
2022/02/06 10:24:24.575682 [INFO] Executing cleanup logic 2022/02/06
10:24:24.575792 [INFO] CommandService Response:
{"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine
execution has encountered an
error.","returncode":1,"events":[{"msg":"Instance deployment: You
didn't specify a Node.js version in the 'package.json' file in your
source bundle. The deployment didn't install a specific Node.js
version.","timestamp":1644143057,"severity":"INFO"},{"msg":"Instance
deployment: 'npm' failed to install dependencies that you defined in
'package.json'. For details, see 'eb-engine.log'. The deployment
failed.","timestamp":1644143064,"severity":"ERROR"},{"msg":"Instance
deployment failed. For details, see
'eb-engine.log'.","timestamp":1644143064,"severity":"ERROR"}]}]}
2022/02/06 10:24:24.575979 [INFO] Platform Engine finished execution
on command: app-deploy
{
"name": "newbackend",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.1069.0",
"cors": "^2.8.5",
"cryptr": "^6.0.2",
"dotenv": "^10.0.0",
"express": "^4.17.2",
"express-validator": "^6.14.0",
"influx": "^5.9.2",
"jsonwebtoken": "^8.5.1",
"moment": "^2.29.1",
"mongoose": "^6.2.0",
"morgan": "^1.10.0",
"multer": "^1.4.4",
"sharp": "^0.30.0",
"validator": "^13.7.0"
}
}
This is my package.json file. It is a simple nodejs app that serves as an API. Now the problem is with the installation of sharp package. If something is missing, please correct me.
I know there is a problem with NPM install but I don't know how to resolve this on AWS CodePipeline.
Any help will be appreciated.
Thanks

Cannot find module autocomplete while deploying a serverless application

I have been trying to deploy a java application using serverless deploy command. But I am getting weird error:
internal/modules/cjs/loader.js:589
throw err;
^
Error: Cannot find module '../lib/utils/autocomplete'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:587:15)
at Function.Module._load (internal/modules/cjs/loader.js:513:25)
at Module.require (internal/modules/cjs/loader.js:643:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/codebuild/output/src042580792/src/node_modules/.bin/serverless:5:22)
at Module._compile (internal/modules/cjs/loader.js:707:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
at Module.load (internal/modules/cjs/loader.js:605:32)
at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
at Function.Module._load (internal/modules/cjs/loader.js:536:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app#1.0.0 deploy: `serverless deploy "--stage" "staging"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#1.0.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Right now I have been using the latest 1.32.0 serverless and my package.json looks like this:
{
"name": "my-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"request": "^2.87.0",
"serverless": "^1.32.0",
"serverless-sam": "^0.1.0"
},
"devDependencies": {
"serverless-offline": "^3.25.4"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"deploy": "node_modules/.bin/serverless deploy"
},
"author": "privatejava",
"license": "ISC"
}
rm -rf node_modules/
npm install
Solves it for me.

Hyperledger composer test code

I was following the instructions on IBM hyperledger composer developer guide, but when I did compiling, it failed and appeared this error.
> mocha -t 0 --recursive && cucumber-js
Sample
1) "before each" hook for "Alice can read all of the assets"
0 passing (912ms)
1 failing
1) Sample "before each" hook for "Alice can read all of the assets":
SyntaxError: Failed to parse /Users/calvinlin007/Documents/hyperledger-composer/my-network/lib/sample.js: The keyword 'const' is reserved (17:0)
at new Script (node_modules/composer-common/lib/introspect/script.js:55:27)
at ScriptManager.createScript (node_modules/composer-common/lib/scriptmanager.js:61:16)
at Object.process (node_modules/composer-common/lib/businessnetworkdefinition.js:507:69)
at Function.processFile (node_modules/composer-common/lib/businessnetworkdefinition.js:578:27)
at items.forEach (node_modules/composer-common/lib/businessnetworkdefinition.js:563:39)
at Array.forEach (native)
at Function.processDirectory (node_modules/composer-common/lib/businessnetworkdefinition.js:562:15)
at Function.fromDirectory (node_modules/composer-common/lib/businessnetworkdefinition.js:498:35)
at adminConnection.createProfile.then.then (test/sample.js:66:50)
npm ERR! Darwin 16.7.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test-inner"
npm ERR! node v6.11.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! my-network#0.1.6 test-inner: `mocha -t 0 --recursive && cucumber-js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-network#0.1.6 test-inner script 'mocha -t 0 --recursive && cucumber-js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the my-network package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! mocha -t 0 --recursive && cucumber-js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs my-network
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls my-network
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/calvinlin007/Documents/hyperledger-composer/my-network/npm-debug.log
npm ERR! Test failed. See above for more details.
This is my .eslintrc.yml configuration
env:
es6: true
node: true
mocha: true
extends: 'eslint:recommended'
parserOptions:
ecmaVersion: 2015
sourceType:
- script
Cuz I have searched the problem and it should be EMCAScript version,
but I tried changing it and it didn't work.
I've checked my macOS is 10.12. and here's my package.json
{
"engines": {
"composer": "^0.11.0 || ^0.12.0 || ^0.13.0"
},
"name": "my-network",
"version": "0.1.6",
"description": "My Commodity Trading network",
"networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/basic-sample-network/networkimage.svg",
"networkImageanimated": "https://hyperledger.github.io/composer-sample-networks/packages/basic-sample-network/networkimageanimated.svg",
"scripts": {
"prepublish": "mkdirp ./dist ; composer archive create --sourceType dir --sourceName . -a ./dist/my-network.bna",
"pretest": "npm run lint",
"lint": "eslint .",
"postlint": "npm run licchk",
"licchk": "license-check",
"postlicchk": "npm run doc",
"doc": "jsdoc --pedantic --recurse -c jsdoc.json",
"test-inner": "mocha -t 0 --recursive && cucumber-js",
"test-cover": "nyc npm run test-inner",
"test": "npm run test-inner"
},
"repository": {
"type": "git",
"url": "https://github.com/hyperledger/composer-sample-networks.git"
},
"keywords": [
"sample",
"composer",
"composer-network"
],
"author": "Hyperledger Composer",
"license": "Apache-2.0",
"devDependencies": {
"browserfs": "^1.2.0",
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"composer-admin": "^0.11.0",
"composer-cli": "^0.11.0",
"composer-client": "^0.11.0",
"composer-connector-embedded": "^0.11.0",
"composer-cucumber-steps": "^0.11.0",
"cucumber": "^2.2.0",
"eslint": "^3.6.1",
"istanbul": "^0.4.5",
"jsdoc": "^3.4.1",
"license-check": "^1.1.5",
"mkdirp": "^0.5.1",
"mocha": "^3.2.0",
"moment": "^2.17.1",
"nyc": "^11.0.2"
},
"license-check-config": {
"src": [
"**/*.js",
"!./coverage/**/*",
"!./node_modules/**/*",
"!./out/**/*",
"!./scripts/**/*"
],
"path": "header.txt",
"blocking": true,
"logInfo": false,
"logError": true
},
"nyc": {
"exclude": [
"coverage/**",
"features/**",
"out/**",
"test/**"
],
"reporter": [
"text-summary",
"html"
],
"all": true,
"check-coverage": true,
"statements": 100,
"branches": 100,
"functions": 100,
"lines": 100
}
}
Does anyone know how to solve this problem ## ?
on your first problem - the sample.js test script - you have copied the Unit Test script contents into lib/sample.js and that is why you have your problems - ie 'const' error - that file is the Transaction Processor functions script. You should (as per the Developer Tutorial) paste the Unit test script into the file located at test/sample.js. I think perhaps the fact that the filenames (in both 'lib' and 'test' subdirectories) are the same, has caused some confusion - think I will get that changed to improve user experience. The other Angular error (mentioned earlier) still stands.
On your second posting (Angular module errors). A local Composer playground install has dependencies on Angular (note the Developer guide uses the online playground). Check out package.json for that list of angular dependencies. Doesn't look like your playground installed correctly, if its showing missing dependencies (#angular/core etc) Suggest to clear down docker ps -aq | xargs docker rm -f and docker images -aq | xargs docker rmi -f (warning: clears down all docker containers in your dev environment) then install it (as a non-privileged user) using the one-liner - ie npm uninstall -g composer-playground - installs playground in a docker container using the command curl -sSL https://hyperledger.github.io/composer/install-hlfv1.sh | bash .
This is what npm list command returns
Calvinde-MacBook-Air:my-network calvinlin007$ npm list -g --depth=0
/usr/local/lib
├── composer-cli#0.12.2
├── composer-playground#0.12.2
├── composer-rest-server#0.12.2
├── generator-hyperledger-composer#0.12.2
├── npm#3.10.10
└── yo#2.0.0
npm ERR! peer dep missing: #angular/core#^4.0.3, required by #ng-bootstrap/ng-bootstrap#1.0.0-beta.2
npm ERR! peer dep missing: #angular/core#>=4.0.0, required by ngx-clipboard#8.0.4
npm ERR! peer dep missing: #angular/common#^4.0.3, required by #ng-bootstrap/ng-bootstrap#1.0.0-beta.2
npm ERR! peer dep missing: #angular/common#>=4.0.0, required by ngx-clipboard#8.0.4
npm ERR! peer dep missing: #angular/forms#^4.0.3, required by #ng-bootstrap/ng-bootstrap#1.0.0-beta.2
npm ERR! peer dep missing: #angular/platform-browser#>=4.0.0, required by ngx-clipboard#8.0.4
npm ERR! peer dep missing: core-js#>=2.4.1, required by ngx-clipboard#8.0.4
npm ERR! peer dep missing: #angular/core#>=2.4.1, required by ngx-window-token#0.0.2
npm ERR! peer dep missing: #angular/common#>=2.4.1, required by ngx-window-token#0.0.2
npm ERR! peer dep missing: #angular/platform-browser#>=2.4.1, required by ngx-window-token#0.0.2
npm ERR! peer dep missing: core-js#>=2.4.1, required by ngx-window-token#0.0.2

Baqend boilerplate fails to npm run build

I'm testing out the Baqend boilerplate downloaded from https://www.baqend.com/guide/starter-kits/react/ and when do npm run build, it throws this error:
Creating an optimized production build...
Failed to compile.
Failed to minify the code from this file:
./node_modules/baqend/lib/util/Metadata.js:12
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-redux-starter#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-redux-starter#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Hopefully I'm just using an older version of the SDK?
This works great on localhost!
The package file:
{
"name": "Nurse Uber Web",
"version": "0.1.0",
"private": true,
"dependencies": {
"baqend": "^2.8.6",
"lodash": "^4.17.4",
"prop-types": "^15.5.9",
"react": "^15.6.1",
"react-bootstrap": "^0.31.3",
"react-dom": "^15.6.1",
"react-redux": "^5.0.6",
"react-router": "^4.1.2",
"react-router-dom": "^4.1.2",
"redux": "^3.7.2",
"redux-baqend": "^1.0.4",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
"react-scripts": "^1.0.11"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom"
}
}
according to this link it's considered bad practice to import a libraries sources directly. You can avoid this problem by simply importing the compiled version. Just change import { db } from 'baqend/lib/baqend' to import { db } from 'baqend' in all your application sources (store.js and Messages.js in the starter) and it should work. Thank you for pointing this out.

Why do I get UNMET PEER DEPENDENCY when I install karma and gulp-karma?

Following this tutorial I would like to use karma for testing. When I install karma and gulp-karma I get the error message below. It says karma#1.3.0 is not installed which is needed for gulp-karma. When I install karma it says the same.
Now, I can't decide whether it is installed correctly or not.
I have tried to remove node_modules directory, clearing chache, upgrading npm and start it from scratch, the result is the same.
npm version: 3.10.8
package.json:
{
"name": "ui.spa",
"version": "1.0.0",
"description": "Framework module for Digital Library",
"main": "Gulpfile.js",
"dependencies": {
"bower": "^1.7.9",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-inject": "^4.1.0",
"gulp-karma": "0.0.5",
"gulp-typescript": "^2.14.1",
"gulp-util": "^3.0.7",
"jasmine": "^2.5.2",
"jasmine-core": "^2.5.2",
"karma": "^1.3.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.2",
"merge-stream": "^1.0.0",
"phantomjs": "^2.1.7",
"require-dir": "^0.3.0",
"run-sequence": "^1.2.2",
"stream-series": "^0.1.1",
"typings": "^1.4.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
C:\Projects\sayusiando.visualstudio.com_git\DigitalLibrary\src\Framework\Framework.UI.Spa>npm
install karma --save ui.spa#1.0.0
C:\Projects\sayusiando.visualstudio.com_git\DigitalLibrary\src\Framework\Framework.UI.Spa
`-- UNMET PEER DEPENDENCY karma#1.3.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.0.0
(node_modules\chokidar\node_modules\fsevents): npm WARN notsup
SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for
fsevents#1.0.14: wanted {"os":"darwin","arch":"any"} (current:
{"os":"win32","arch":"x64"}) npm WARN gulp-karma#0.0.5 requires a peer
of karma#>=0.10 <=0.13 but none was installed. npm WARN ui.spa#1.0.0
No repository field. npm ERR! code 1
C:\Projects\sayusiando.visualstudio.com_git\DigitalLibrary\src\Framework\Framework.UI.Spa>npm
install gulp-karma --save ui.spa#1.0.0
C:\Projects\sayusiando.visualstudio.com_git\DigitalLibrary\src\Framework\Framework.UI.Spa
+-- gulp-karma#0.0.5 `-- UNMET PEER DEPENDENCY karma#1.3.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.0.0
(node_modules\chokidar\node_modules\fsevents): npm WARN notsup
SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for
fsevents#1.0.14: wanted {"os":"darwin","arch":"any"} (current:
{"os":"win32","arch":"x64"}) npm WARN gulp-karma#0.0.5 requires a peer
of karma#>=0.10 <=0.13 but none was installed. npm WARN ui.spa#1.0.0
No repository field.
C:\Projects\sayusiando.visualstudio.com_git\DigitalLibrary\src\Framework\Framework.UI.Spa>
The root of the problem is that gulp-karma package is deprecated now.