I have an electron/react application which works fine in development mode, but when it comes to building and packaging it gives this error when i run yarn electron-pack
$ build -mw
/bin/sh: build: command not found
error Command failed with exit code 127.
this happened after i installed some additional packages ( the packaging before that worked fine )
this is my scripts in package.json file :
"scripts": {
"start": "rescripts start",
"build": "rescripts build",
"test": "rescripts test",
"eject": "react-scripts eject",
"electron-dev": "concurrently \"BROWSER=none yarn start\" \"wait-on
http://localhost:3000 && electron .\"",
"postinstall": "electron-builder",
"preelectron-pack": "yarn build",
"electron-pack": "build -mw"
},
and this is the devDependencies
"devDependencies": {
"#rescripts/cli": "^0.0.16",
"#rescripts/rescript-env": "^0.0.14",
"concurrently": "^6.2.0",
"electron": "^13.1.8",
"electron-builder": "^22.11.7",
"typescript": "^4.3.5",
"wait-on": "^6.0.0"
}
a temporary solution that i found is removing node modules files and run npm install
rm -rf node_modules
npm install
Related
I am trying to start a react and node based application that works fine in mac systems, but when I am trying to start in windows, it's throwing an error.
The command to start is - yarn start:all
The script entries in package.json file are -
"scripts": {
"docs": "jsdoc2md src/*.js src/**/*.js > API.md",
"build:dev": "better-npm-run build:dev",
"build:production": "better-npm-run build:production",
"style": "eslint --fix --ext .js,.jsx src config",
"unit": "cross-env LOG_LEVEL=warn jest",
"coverage": "cross-env LOG_LEVEL=warn helix test --coverage",
"test": "yarn style && yarn coverage",
"start:inspect": "nodemon --inspect .",
"eject": "helix eject",
"start": "better-npm-run start:stage",
"start:ordersPresentationStage": "micro_cancellations_path=http://localhost:3001/cancellations/micro yarn --cwd ../orders-presentation-helix startStage",
"start:laptopProxyServer": "node tools/laptopDevProxyServer.js",
"start:all": "concurrently --kill-others -n proxy,orders,cancellation \"yarn start:laptopProxyServer\" \"yarn start:ordersPresentationStage\" \"yarn start\"",
"start:production": "yarn run build:production && cross-env ASSET_PATH=/cancellationspres/assets/ NODE_ENV=production node .",
"build-stats:development": "yarn start -- --analyze",
"build-stats:production": "yarn build -- --analyze",
"generate:component": "helix generate:component",
"clean": "rimraf ./build",
"std-version": "standard-version"
},
The error that I am getting is -
'micro_cancellations_path' is not recognized as an internal or external command, operable program or batch file.
I assume the start:ordersPresentationStage part of scripts is unable to execute because the line cannot be processed in windows system, but I am not able to find an alternative statement for the same. Please help!
I have downloaded following React Material template
template
Followed steps from documentation
package.json
{
"name": "material-dashboard-react",
"version": "1.6.0",
"description": "Material Dashboard React. Coded by Creative Tim",
"private": false,
"main": "dist/index.js",
"scripts": {
"start": "NODE_PATH=./src react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm start",
"lint:check": "eslint . --ext=js,jsx; exit 0",
"lint:fix": "eslint . --ext=js,jsx --fix; exit 0",
"build-package-css": "cp src/assets/css/material-dashboard-react.css dist/material-dashboard-react.css",
"build-package": "npm run build-package-css && babel src --out-dir dist"
},
}
Getting the following error
It is because you are using Windows. The project was likely ran on unix based computers before (NODE_PATH=./src is not a windows way of defining environment variables). You can either fix it by using the Windows syntax "start": "set NODE_PATH=./src react-scripts start", (your project will not run on unix machines) or use a cross-env library for defining your environment : https://www.npmjs.com/package/dotenv
For anyone wondering, I had the same issue with the same template and my solution was to configure a file in the project root as specified in this link.
I'm using docker and my working directory is in the /app directory, so I added this line in my tsconfig.json file at the root of my react app folder:
"compilerOptions": {
...,
"baseUrl": "/app/src",
}
created my project with my app
This is the project.json file. That I have created
{
"name": "detox",
"version": "0.0.1",
"private": true,
"scripts": {
"ios": "react-native run-ios",
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"test:e2e":"navicotrackapp test",
"test:e2e:build":"navicotrackapp build"
},
"dependencies": {
"react": "16.6.1",
"react-native": "0.57.7"
},
"devDependencies": {
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.49.2",
"react-test-renderer": "16.6.1"
},
"jest": {
"preset": "react-native"
},
"detox": {
"configurations": {
"ios.sim.debug": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/navicotrackapp.app",
"build": "xcodebuild -project ios/navicotrackapp.xcodeproj -scheme navicotrackapp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"name": "iPhone XR"
}
}
}
}
However. When I ran the test this was the out come:
Questions:
What did I do wrong
How do I fix it?
For those coming with yarn 127 error code problem
Take a look on https://github.com/reactstrap/reactstrap/issues/711
Most probably you just need to run in console yarn :)
Replace your scripts values with these, and try again:
"scripts": {
"ios": "react-native run-ios",
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"test:e2e":"npm run test",
"test:e2e:build":"npm run build" // THIS SCRIPT WILL STILL BREAK FOR YOU
},
The last two are the important ones!
You need to prefix a script command with npm run or yarn if the script references another script in your package.json.
So instead of a script calling navicotrackapp test it would call npm run test OR yarn test.
NOTE:
In you example it looks like the terminal is failing on the script navicotrackapp build. Know that you do not have a build script defined so if you replace the script with npm run build it will still fail. You'll need to add a build script in if you want it to work!
"scripts": {
"ios": "react-native run-ios",
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"build": // DO SOMETHING HERE!!!!,
"test:e2e":"npm run test",
"test:e2e:build":"npm run build"
},
Try below commands it works for me
$ npm install #ionic/app-scripts#latest --save-dev
$ ionic serve
Just use https://app.netlify.com/drop to deploy manually on Netlify
first run this command
npm run build
OR
yarn run build
Then drag and drop the build folder on the website above.
Try this, and please take care of the spaces.
It worked for me though. I added CI= in the capital before npm run build. Double-check if you did git add. , git commit -m "first commit" and git push -u origin before your final deployment.
UPDATE: Seems the error is related to one of my private packages
I am using a private module for my react app, built with heroku-create-react-app.
this is my .npmrc inside the project root folder:
//registry.npmjs.org/:_authToken={NPM_TOKEN}
init.author.name=My.Name
scope=username
#username:registry=https://registry.npmjs.org/
and my package.json
"dependencies": {
"#myname/my-component": "^0.1.9",
...
}
"scripts": {
"build-css": "node-sass-chokidar ./src/ -o ./src/",
"watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive",
"start-js": "react-scripts start",
"start": "npm-run-all -p watch-css start-js",
"build-js": "react-scripts build",
"build": "npm-run-all build-css build-js",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
On heroku I set up the environment variable as
NPM_TOKEN and set the token as its value.
When pushing to heroku I get this error:
remote: -----> Building dependencies
remote: Installing node modules (package.json + package-lock)
remote: npm ERR! code E404
remote: npm ERR! 404 Not Found: #myname/my-component#https://registry.npmjs.org/#my-name/my-component/-/my-component-0.1.9.tgz
remote:
I don't see the GitHub repository named heroku-create-react-app, but if it's bootstrapped using create-react-app, the variable name needs to start with "REACT_APP_" for it to be available under the variable process.env. This post has more information: http://uidevdaily.com/2018/how-to-set-environment-specific-variables-in-a-react-app.
Any advise on how to achieve live-reloading when implementing a Chrome Extension with create-react-app? Currently I yarn run build every time there is a change.
I managed to do that using create-react-app by:
npm i npm-watch --save-dev
Then in the package.json
{
"name": "react-app",
"version": "0.1.0",
"private": false,
"devDependencies": {
"npm-watch": "^0.1.8",
"react-scripts": "0.9.5",
},
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"watch": "npm-watch" //add this to the script
},
"watch": { //add this outside the script
"build": "src/"
}
}
I got this working with fswatch on Mac (had to brew install fswatch):
fswatch -o ~/$PATH_TO_YOUR_PROJECT/src | xargs -n1 -I{} npm run build
This will run npm run build anytime the src directory changes (which is what I was doing manually beforehand anyways)
Note: my manifest is pointing to the build directory for my popup.
I achieve live-reloading when implementing a Chrome Extension V3 with create-react-app. Whatever you change page or content script, all things is auto refresh/reload.
https://github.com/Godiswill/cra-crx-boilerplate