missing script: start Electron - angularjs

I try to create my first angular application using Electron, so i follow this guide here :
Electron Documentation
so i do step by step what is in the guide but when i do this command :
npm start
I get this error here:
$ npm start
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.9.4
npm ERR! npm v3.10.10
npm ERR! missing script: start
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! D:\FreeLancer\angular2electron\npm-debug.log
package.json
{
"name": "angular2electron",
"version": "1.0.1",
"description": "my first angularjs",
"main": "main.js",
"dependencies": {
"electron": "^1.4.13"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "LAIDANI Youcef",
"license": "MIT"
}
Someone have an idea about this problem?
Thank you.

npm start runs the script in the package.json. To get an electron app running with it just add electron . to the start script :
package.json
{
"name": "angular2electron",
"version": "1.0.1",
"description": "my first angularjs",
"main": "main.js",
"dependencies": {
"electron": "^1.4.13"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start" : "electron ."
},
"author": "LAIDANI Youcef",
"license": "MIT"
}

Related

when i try to run the project with library #google/model-viewer by npm start i get this error

this is my package.json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"#google/model-viewer": "^1.11.0",
"react": "^18.0.0"
}
}
`PS C:\Users\AA\Desktop\3Dpro\my-app> npm start
npm ERR! Missing script: "start"
npm ERR!
npm ERR! Did you mean one of these?
npm ERR! npm star # Mark your favorite packages
npm ERR! npm stars # View packages marked as favorites
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\AA\AppData\Local\npm-cache_logs\2022-04-05T20_22_54_567Z-debug-0.log
PS C:\Users\AA\Desktop\3Dpro\my-app>
I am using a library for 3D ( #google/model-viewer)
this is my code:
import '#google/model-viewer'
import React, { Component } from 'react'
export default class PersonalDesign extends Component {
render() {
return (
)
}
}
Looks like your package.json file is missing the scripts for some reason. Add them back in. You also appear to be missing the react-dom and react-scripts dependencies.
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"#google/model-viewer": "^1.11.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-scripts": "^4.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
After updating/saving your package.json file, run npm i to install the dependencies and then run npm start to start your project.

Cannot find module 'react-bootstrap' with module other than commonjs

I use React with Typescript, but cannot use React Bootstrap with a module other than commonjs.
I first install react-bootstrap package:
$ npm i react-bootstrap
And then write the code to use it, for example,
// src/index.tsx
import { Button } from 'react-bootstrap';
But compiling it by npx tsc get an error Cannot find module 'react-bootstrap' or its corresponding type declarations. When I googled about this issue, I found that react-bootstrap has its own types (so I do not need #types/react-bootstrap).
If I set module in tsconfig.json to commonjs, then I can compile it correctly.
Why cannot I use react-bootstrap however? Are there other ways to use React Bootstrap together with Typescript (and with modules other than commonjs)?
The minimal example here:
package.json:
{
"name": "foo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"type": "npx tsc --noEmit",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"typescript": "^3.9.5"
},
"dependencies": {
"react-bootstrap": "^1.0.1"
}
}
tsconfig.json:
{
"compilerOptions": {
"target": "es2015",
"module": "es2015",
"skipLibCheck": true
},
"include": [
"src/**/*"
]
}
src/index.tsx:
import { Button } from 'react-bootstrap';
Then run
$ npm run type
> foo#1.0.0 type /home/bar/src/foo
> npx tsc --noEmit
src/index.tsx(1,24): error TS2307: Cannot find module 'react-bootstrap' or its corresponding type declarations.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! foo#1.0.0 type: `npx tsc --noEmit`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the foo#1.0.0 type 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! /home/bar/.npm/_logs/2020-07-04T12_11_17_351Z-debug.log
Clean npm modules cache using
$ npm cache clean --force
Delete node_modules by $ rm -rf node_modules package-lock.json or delete it manually
Install npm modules npm install
This worked for me. Hopes it works for you too.

Babel doesn't recognise React component

I'm trying to use babel to compile some React code into javascript. My project directory is setup like this:
In my App.jsx file under src I have:
const continents = ['Africa','America','Asia','Australia','Europe'];
const helloContinents = Array.from(continents, c => `Hello ${c}!`);
const message = helloContinents.join(' ');
const element = (
<div title="Outer div">
<h1>{message}</h1>
</div>
);
ReactDOM.render(element, document.getElementById('contents'));
I have added a babel.rc file under src and it contains
{
"presets": [
["#babel/preset-env", {
"targets": {
"ie": "11",
"edge": "15",
"safari": "10",
"firefox": "50",
"chrome": "49"
}
}],
"#babel/preset-react"
]
}
And my package.json file looks like:
{
"name": "pro-mern-stack-2",
"version": "1.0.0",
"description": "learning MERN",
"main": "index.js",
"scripts": {
"start": "node server/server.js",
"test": "echo \"Error: no test specified\" && exit 1",
"compile": "babel src --out-dir public"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"#babel/cli": "^7.2.3",
"#babel/core": "^7.2.2",
"#babel/preset-env": "^7.2.3",
"#babel/preset-react": "^7.9.4",
"babel-preset-react": "^6.24.1"
}
}
When I run npm run compile I get the following error:
> pro-mern-stack-2#1.0.0 compile /home/vagrant/pro-mern-stack-2
> babel src --out-dir public
SyntaxError: src/App.jsx: Unexpected token (6:2)
4 |
5 | const element = (
> 6 | <div title="Outer div">
| ^
7 | <h1>{message}</h1>
8 | </div>
9 | );
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pro-mern-stack-2#1.0.0 compile: `babel src --out-dir public`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pro-mern-stack-2#1.0.0 compile 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! /home/vagrant/.npm/_logs/2020-05-23T13_50_03_224Z-debug.log
vagrant#scotchbox:~/pro-mern-stack-2$
App.js is produced under public however the React component is commented out. To the best of my knowledge I have included everything I need for this to work. Any help would be appreciated.
It's not called babel.rc, but .babelrc, also your .babelrc must be in the root directory of your project, not in in your src/ directory.

I'm trying to deploy my Gatsby Blog on Github pages, but "npm run deploy" returns error

I tried to build and deploy my Gatsby blog on github pages.
I followed Gatsby's docs about deploy: https://www.gatsbyjs.org/docs/deploy-gatsby/
I run the following command:
npm run deploy
I encountered:
Cannot read property 'email' of null
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gatsby-starter-hello-world# deploy: `gatsby build && gh-pages -b master -d public`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gatsby-starter-hello-world# 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! /Users/ChaewonKong/.npm/_logs/2018-09-20T09_34_57_114Z-debug.log
This is my gatsby-config.js looks like:
module.exports = {
siteMetadata: {
title: `Leon Kong's Blog`
},
plugins: [
{
resolve: `gatsby-source-filesystem`,
options: {
name: `src`,
path: `${__dirname}/src/`
}
},
`gatsby-transformer-remark`
]
};
This is my package.json:
{
"name": "gatsby-starter-hello-world",
"description": "Gatsby hello world starter",
"license": "MIT",
"scripts": {
"develop": "gatsby develop",
"build": "gatsby build",
"serve": "gatsby serve",
"deploy": "gatsby build && gh-pages -b master -d public"
},
"dependencies": {
"gatsby": "^2.0.0",
"gatsby-source-filesystem": "^2.0.1",
"gatsby-transformer-remark": "^2.1.3",
"react": "^16.5.1",
"react-dom": "^16.5.1"
},
"devDependencies": {
"gh-pages": "^2.0.0"
}
}
Plus, I'm trying to make an user/organization site like:
https://username/github.io
I'm just guessing email is not set in your git config. Try to run git config user.email to see if it's there.
You can follow this article on how to add it https://help.github.com/articles/setting-your-commit-email-address-in-git/.
Also, here are docs on how to set a github page.

Gatsby Deployment to Github Failing

Struggling with this one. I've downloaded and installed locally, this Gatsby starter pack:
https://github.com/ChangoMan/gatsby-starter-dimension .
And i'm trying to deploy to my github web page:
https://reenaverma.github.io/
I've followed the instructions, but keep getting this error when I run npm run deploy:
> gatsby-starter-dimension#1.0.0 deploy /Users/reenaverma/development/gatsby-starter-dimension
> gatsby build && gh-pages -b master -d public
success delete html and css files from previous builds — 0.014 s
success open and validate gatsby-config — 0.004 s
info One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's not any stale
data
success copy gatsby files — 0.014 s
success onPreBootstrap — 0.858 s
success source and transform nodes — 0.111 s
success building schema — 0.239 s
success createLayouts — 0.006 s
success createPages — 0.019 s
success createPagesStatefully — 0.005 s
success onPreExtractQueries — 0.004 s
success update schema — 0.102 s
success extract queries from components — 0.070 s
success run graphql queries — 0.098 s
success write out page data — 0.004 s
success write out redirect data — 0.001 s
success onPostBootstrap — 0.001 s
info bootstrap finished - 4.183 s
success Building CSS — 2.647 s
success Building production JavaScript bundles — 4.936 s
success Building static HTML for pages — 1.787 s
info Done building in 13.557 sec
sh: gh-pages: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! gatsby-starter-dimension#1.0.0 deploy: `gatsby build && gh-pages -b master -d public`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the gatsby-starter-dimension#1.0.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! /Users/reenaverma/.npm/_logs/2018-05-30T17_41_52_319Z-debug.log
Here's my package.json:
{
"name": "gatsby-starter-dimension",
"description": "Gatsby Starter - Dimension by HTML5 UP",
"version": "1.0.0",
"author": "Hunter Chang",
"dependencies": {
"gatsby": "^1.9.235",
"gatsby-link": "^1.6.39",
"gatsby-image": "^1.0.42",
"gatsby-plugin-google-analytics": "^1.0.24",
"gatsby-plugin-react-helmet": "^1.0.8",
"gatsby-plugin-sass": "^1.0.23",
"gatsby-plugin-sharp": "^1.6.41",
"gatsby-remark-copy-linked-files": "^1.5.30",
"gatsby-remark-images": "^1.5.56",
"gatsby-source-filesystem": "^1.5.27",
"gatsby-transformer-remark": "^1.7.37",
"gatsby-transformer-sharp": "^1.6.22",
"lodash": "^4.17.4"
},
"homepage": "https://github.com/ChangoMan/gatsby-starter-dimension",
"keywords": [
"gatsby"
],
"license": "MIT",
"main": "n/a",
"repository": {
"type": "git",
"url": "https://github.com/ChangoMan/gatsby-starter-dimension.git"
},
"scripts": {
"dev": "gatsby develop",
"lint": "./node_modules/.bin/eslint --ext .js,.jsx --ignore-pattern public .",
"test": "echo \"Error: no test specified\" && exit 1",
"develop": "gatsby develop",
"build": "gatsby build",
"deploy": "gatsby build && gh-pages -b master -d public",
"fix-semi": "eslint --quiet --ignore-pattern node_modules --ignore-pattern public --parser babel-eslint --no-eslintrc --rule '{\"semi\": [2, \"never\"], \"no-extra-semi\": [2]}' --fix gatsby-node.js"
},
"devDependencies": {
"gh-pages": "^1.1.0",
"prettier": "^1.12.0"
}
}
And gatsby-config.sj:
module.exports = {
siteMetadata: {
title: "Gatsby Starter - Dimension by HTML5 UP",
author: "Hunter Chang",
description: "A Gatsby.js Starter based on Dimension by HTML5 UP"
},
pathPrefix: '/',
plugins: [
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/src/posts`,
name: "posts",
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 630,
},
},
"gatsby-remark-copy-linked-files",
],
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
`gatsby-plugin-react-helmet`,
`gatsby-plugin-sass`
],
}
got it working! I didnt install this:
npm install gh-pages --save-dev

Resources