Why I'm not able to run npm scripts? [duplicate] - laravel

I was running an Electron project, and everything worked just fine. But now when I run any of the scripts in my package.json (including npm start), it just escapes a line and doesn't do anything.
My package.json:
{
"name": "interclip-desktop",
"version": "0.0.7",
"description": "Interclip for desktop",
"repository": "https://github.com/aperta-principium/Interclip-desktop",
"main": "main.js",
"scripts": {
"start": "electron .",
"package-mac": "electron-packager . --overwrite --asar=true --platform=darwin --arch=x64 --icon=assets/icons/mac/icon.icns --prune=true --out=release-builds",
"package-win": "electron-packager . Interclip --overwrite --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"Interclip\"",
"package-linux": "electron-packager . Interclip --overwrite --asar=true --platform=linux --arch=x64 --icon=assets/icons/png/icon.png --prune=true --out=release-builds",
"win-install": "node installers/windows/createinstaller.js",
"postinstall": "electron-builder install-app-deps",
"build": "electron-builder --linux",
"release": "electron-builder --linux --publish always"
},
"keywords": [
"Desktop",
"Interclip"
],
"author": "Filip Troníček",
"license": "MIT",
"devDependencies": {
"electron": "^7.1.2",
"electron-builder": "^22.1.0",
"electron-installer-dmg": "^3.0.0",
"electron-packager": "^14.1.1",
"electron-reload": "^1.5.0",
"electron-winstaller": "^4.0.0"
},
"dependencies": {
"axios": "^0.19.0",
"mousetrap": "^1.6.3"
},
"build": {
"appId": "com.aperta-principium.interclip",
"productName": "Interclip",
"mac": {
"category": "public.app-category.utilities"
},
"dmg": {
"icon": false
},
"linux": {
"target": [
"AppImage"
],
"category": "Utility"
}
}
}
I tried updating NPM, didn't work. When I tried in different projects, also doesn't work.
Thanks in advance

npm has a ignore-scripts configuration key. It's expected value is a Boolean and it's set to false by default.
Perhaps it has inadvertently been set to true.
To get/set the ignore-scripts configuration you can utilize the npm-config command:
Check its current setting by running:
npm config get ignore-scripts
If the aforementioned command returns true then reset it to false by running:
npm config set ignore-scripts false

If you are using an integrated terminal (such as the VsCode integrated terminal) try running your npm "run dev' command from your PowerShell (or cmd) terminal. This error arises as a result of your integrated terminal not recognizing your command (especially if you created your app with a git bash terminal).
Try this, and I hope it helps someone cause it always works for me. Cheers!!!

Related

Yarn does not see workspaces

I have the following configuration in a root workspace. The strange thing is that for backend it works, but for frontend - doesn't, no matter how I rename this
{
"private": true,
"name": "root",
"workspaces": [
"packages/frontend",
"packages/backend"
],
"scripts": {
"client": "yarn workspace frontend start",
"client-test": "yarn workspace frontend test",
"server": "yarn workspace backend start",
"start": "conc --kill-others-on-fail \"yarn client\" \"yarn server\""
},
"devDependencies": {
"concurrently": "^7.6.0"
}
}
And it always says: $ yarn workspace frontend test
error Unknown workspace "frontend".
info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I tried to start from all directories, nothing works
The thing is that it does not matter how folders are called inside of "packages", the important thing is that package.json of each workspace should be called correspondingly:
{
"name": "frontend",
"version": "1.0.0",
"private": true,
...
}

Electron-Forge SQLite3 database not accessible on MacOS Darwin build after unzipping

I'm having some issues with a CRUD desktop application I developed with the help of a freelancer. It's an electron-forge build that works seamlessly on Windows 10, and works on MacOS initially when accessing the out folder, the strange thing happens when:
I use npm run publish to zip the Mac/Darwin instance
I manually package.zip the results of npm run make
When I do this, and unzip the file to run, the SQLite integration fails completely. The app appears to be working upon start, but no changes can be made to the DB objects, nor can new objects be made.
The freelancer who put together the DB integration said he was not able to solve this issue, but it's impossible to put apps in marketplaces without zipping the application for delivery. I can post code if necessary, I just don't even know what aspect of the code would be relevant, and feel like there has to be something I can install/put in my package.json that might solve this, but I'm just not sure.
Here is my package.json file in case that is helpful:
{
"name": "C",
"productName": "C",
"version": "1.0.2",
"description": "My Electron application description",
"main": "src/index.js",
"scripts": {
"start": "cross-env NODE_ENV=development electron-forge start",
"package": "electron-forge package",
"make": "cross-env NODE_ENV=production electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"keywords": [],
"author": {
"name": "A",
"email": "xxx#gmail.com"
},
"license": "NA",
"config": {
"forge": {
"packagerConfig": {
"icon": "src/images/n.ico"
},
"makers": [
{
"name": "#electron-forge/maker-squirrel",
"config": {
"name": "C"
}
},
{
"name": "#electron-forge/maker-zip",
"platforms": [
"darwin"
]
},
{
"name": "#electron-forge/maker-deb",
"config": {}
},
{
"name": "#electron-forge/maker-rpm",
"config": {}
}
]
}
},
"dependencies": {
"axios": "^0.21.1",
"bootstrap": "^4.6.0",
"cross-env": "^7.0.3",
"ebay-oauth-nodejs-client": "^1.2.1",
"electron-better-ipc": "^1.1.1",
"electron-squirrel-startup": "^1.0.0",
"electron-store": "^7.0.2",
"jquery": "^3.6.0",
"json-csv": "^3.0.6",
"sequelize": "^6.5.0",
"sqlite3": "^5.0.0"
},
"devDependencies": {
"#electron-forge/cli": "^6.0.0-beta.54",
"#electron-forge/maker-deb": "^6.0.0-beta.54",
"#electron-forge/maker-rpm": "^6.0.0-beta.54",
"#electron-forge/maker-squirrel": "^6.0.0-beta.54",
"#electron-forge/maker-zip": "^6.0.0-beta.54",
"electron": "10.1.5"
}
}
I found that by simply creating a DMG target (see https://www.electronforge.io/config/makers/dmg) that I did not need to worry about unzipping process. I believe DMG is the ideal approach for packaging Mac OS apps that have something like a SQLite database integration within.

Expo - standalone APK crashing when running on physical device; app working on expo-cli

First off, I'm new to react-native so please excuse my missing knowledge regarding troubleshooting.
I have built a basic app using Expo, which runs perfectly fine when I run expo start and scan the QR code to run it on my physical device.
I then ran expo build:android in my terminal and selected apk to create an apk file. It installs, but when I try to open the app on my phone, it crashes straight away. I'm not sure why this happens, or how to troubleshoot it.
Some steps I have taken:
Reinstalled expo-cli
Reinstalled react-native
Ran npm-update
Manually downgraded my sdkVersion to 37.0.0 in my app.json file (as suggested by online forums)
Here is my app.json file:
{
"expo": {
"name": "FactApp",
"slug": "FactApp",
"sdkVersion": "37.0.0",
"platforms": [
"ios",
"android",
"web"
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"android": {
"package": "com.kmdevops.factapp",
"versionCode": 2,
"config": {
"googleMobileAdsAppId": "ca-app-pub-7529073010403742/8555991419"
}
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.yourcompany.yourappname",
"buildNumber": "1.0.0"
},
"description": ""
}
}
And here is my package.json file:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"#react-native-community/masked-view": "0.1.6",
"#react-navigation/native": "^5.5.1",
"expo": "^37.0.12",
"expo-ads-admob": "~8.1.0",
"expo-linear-gradient": "~8.1.0",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
"react-native-gesture-handler": "~1.6.0",
"react-native-reanimated": "~1.7.0",
"react-native-safe-area-context": "0.7.3",
"react-native-screens": "~2.2.0",
"react-native-web": "~0.11.7",
"react-navigation": "^4.3.9",
"react-navigation-stack": "^2.7.0",
"react-navigator": "0.0.0-0"
},
"devDependencies": {
"babel-preset-expo": "~8.1.0",
"#babel/core": "^7.8.6"
},
"private": true
}
Any help would be greatly appreciated!
So I created a fresh new app with expo-cli and the resulting APK crashed so I figure it's an issue with expo. I used react-native cli to create an apk for this app and it works with no issues

React Native OSX CRNA Compilation of µWebSockets has failed C++11 compiler

Got this issue after ejecting from Expo (with ExpoKit). Had a working environment before ejecting. npm run ios will run with this issue repeating over and over:
Origin: Worker (PID 6336) 12:18:06: [Error] Error: getaddrinfo
ENOTFOUND lcalhost 12:18:06: at errnoException (dns.js:28:10)
12:18:06: at GetAddrInfoReqWrap.onlookup [as oncomplete]
(dns.js:76:26)
Expo XDE will not run at all and repeats this message. XCode includes C++11 compiler.
Error: Compilation of µWebSockets has failed and there is no
pre-compiled binary available for your system. Please install a
supported C++11 compiler and reinstall the module 'uws'.
package.json
{
"name": "OurApp",
"version": "0.0.1",
"private": true,
"devDependencies": {
"babel-eslint": "^8.0.3",
"eslint": "^4.13.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.5.1",
"jest-expo": "^23.0.0",
"react-native-scripts": "1.8.1",
"react-test-renderer": "16.0.0",
"remotedev-rn-debugger": "^0.8.3"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "node node_modules/jest/bin/jest.js --watch",
"postinstall": "remotedev-debugger --hostname lcalhost --port 5678 --injectserver",
"eslint": "./node_modules/.bin/eslint"
},
"remotedev": {
"hostname": "localhost",
"port": 5678
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"#expo/vector-icons": "^6.2.1",
"axios": "^0.17.1",
"expo": "^23.0.0",
"lodash": "^4.17.4",
"prop-types": "^15.6.0",
"react": "16.0.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-23.0.0.tar.gz",
"react-native-elements": "^0.18.5",
"react-native-maps": "^0.19.0",
"react-navigation": "^1.0.0-beta.19",
"react-navigation-redux": "^0.1.0",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"redux-promise": "^0.5.3",
"redux-thunk": "^2.2.0",
"remote-redux-devtools": "^0.5.12"
}
}
app.json
{
"expo": {
"isDetached": false,
"privacy": "unlisted",
"sdkVersion": "23.0.0",
"orientation": "portrait",
"primaryColor": "#ffde00",
"name": "OurApp",
"description": "Desc",
"icon": "./resources/icon.png",
"version": "0.0.1",
"slug": "our-app",
"scheme": "ourapp",
"ios": {
"bundleIdentifier": "se.comp.expo",
"config": {
"googleMapsApiKey": "key"
},
"buildNumber": "1.0.0",
"isRemoteJSEnabled": true,
"supportsTablet": false,
"associatedDomains": [
"myDomain.com"
]
},
"android": {
"package": "se.comp.expo",
"versionCode": 1,
"config": {
"googleMaps": {
"apiKey": "key"
}
},
"permissions": [
"CAMERA",
"ACCESS_FINE_LOCATION"
]
},
"notification": {
"icon": "./resources/icon_notify.png",
"color": "#ffde00",
"androidMode": "collapse",
"androidCollapsedTitle": "#{unread_notifications} new"
},
"loading": {
"icon": "./resources/icon.png",
"backgroundColor": "#000000",
"backgroundImage": "./resources/splash.png",
"hideExponentText": true
},
"splash": {
"backgroundColor": "#000000",
"image": "./resources/splash.png",
"resizeMode": "cover"
},
"androidStatusBar": {
"barStyle": "dark-content",
"backgroundColor": "#ffde00"
},
"facebookAppId": "id",
"facebookDisplayName": "OurApp",
"facebookScheme": "fbId",
"androidShowExponentNotificationInShellApp": true
}
}
As #SyedZainAli mentioned this might be caused by environment. A few things to try then is:
Remove node_modules, run npm cache clean and reinstall
Reinstall NodeJS
Create a new app using CRNA and compare
In my case ejecting and using Expo react-native branch (default behavior) causes the issue. Changing back to official react-native npm package resolves the issue. So should be something on Expo's side.
I don't know if this may help you, but it fixed my issue within docker.
In Docker file
//////////////////////////////////////////////////////////////////////////
FROM node:8.9-alpine
RUN apk add --update \
libc6-compat
//////////////////////////////////////////////////////////////////////////
Needed libc6-compact
so try installing libc6-compat.
I had the same issue (below) when I was trying the start an app I got from my team in Expo. And it turned out that uws version in the project was not compatible with the Node version I was using. - node v10.15.0
Switching the node version to be 8.11.4 using nvm - nvm use 8.11.4 solved my issue. (If there is no 8.11.4 version installed use nvm install 8.11.4 instead)
$ expo start
Starting project at /Users/dugong/development/myApp
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
oteDev] Start server...
--------------------------------------------------------------------------------
[Busy] Launching SocketCluster
1555352786943 - Origin: Worker (PID 63541)
[Error] Error: Compilation of µWebSockets has failed and there is no pre-compiled binary available for your system. Please install a supported C++11 compiler and reinstall the module 'uws'.
at native (/Users/dugong/development/myApp/node_modules/socketcluster-server/node_modules/uws/uws.js:38:19)

React-native command unrecognized

I have installed react-native and built some simple application. I ran it and everything was fine. After a while, I could not run anymore my application, because every time I type "react-native start" in cmd, it gets me something like in the picture below. Does anyone have any idea?
EDIT: package json looks like:
{
"name": "AwesomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "15.3.2",
"react-native": "0.36.0",
"react-native-checkbox": "^1.0.15",
"react-native-mail": "^2.0.0"
},
"jest": {
"preset": "jest-react-native"
},
"devDependencies": {
"babel-jest": "16.0.0",
"babel-preset-react-native": "1.9.0",
"jest": "16.0.2",
"jest-react-native": "16.0.0",
"react-test-renderer": "15.3.2"
}
}
according to me you need to run npm install from your root project dir because you might have deleted some file from node_module folder which will be recovered after running the above command.

Resources