Netlify: Failed to upload file: &{Name:submission-created during build - javascript

I'm trying to use netlify and its lambda function feature to run a node function. Based on https://css-tricks.com/using-netlify-forms-and-netlify-functions-to-build-an-email-sign-up-widget/.
I'm having trouble getting node modules to work (see ImportModuleError","errorMessage":"Error: Cannot find module while using Netlify lambda functions with dependencies)
Currently my netlify.toml has only the following:
[build]
functions = "./functions"
command = "npm run-script build"
and my package.json:
{
"name": "test2",
"version": "1.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "npm install && npm build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/kc1/test2.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/kc1/test2/issues"
},
"homepage": "https://github.com/kc1/test2#readme",
"dependencies": {
"dotenv": "^8.2.0",
"node-fetch": "^2.6.1"
}
}
You can see the deploy log here: https://app.netlify.com/sites/inspiring-ardinghelli-4a4da5/deploys/5fd180d4db83b400073f8694. What am I doing wrong?

Related

“react doesn't exist” in Node.js terminal

I got that error “react doesn't exist” when I'm trying to compile jsx using babel using this command :
npx babel src/index.js --out-file=public/main.js --presets=env,react
both dependencies env and react are configured.
{"name": "React",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"},
"keywords": [],
"author": "",
"license": "ISC"}
any ideas?
Do you add React?
yarn add react
or
npm install react
maybe try add this to script in package.json
{"name": "React",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "babel src/index.js --out-file=public/main.js --presets=env,react"
},
"keywords": [],
"author": "",
"license": "ISC"}
And run command:
yarn dev
or
npm run dev

Git-related Issues uploading to Heroku

I have exactly the same issue as User daffodils. When uploaded to heroku the app fails with a message "npm ERR! missing script: start" But I don't have a start command in my package.json and I do have "web : node app.js" in my Procfile
I don't have a start in my package.json file and the same file worked ok for another similar app on heroku:
{
"name": "tBlogv3withdb",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"engines": {
"node": "13.12.0"
},
"dependencies": {
"body-parser": "^1.18.3",
"ejs": "^2.6.1",
"express": "^4.16.3",
"lodash": "^4.17.15",
"mongoose": "^5.9.10"
}
}
User Daffodils said "I dropped the repo and re-init solved it." - what does this mean exactly?

How to add build script and tests in NodeJs project

I have created a basic todo app which has package.json file as:
{
"name": "to-do-app",
"version": "1.0.0",
"description": "A basic to-do app created using JavaScript.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Sahil Silare",
"license": "MIT",
"dependencies": {
"body-parser": "^1.19.0",
"build": "^0.1.4",
"ejs": "^2.7.1",
"express": "^4.17.1",
"npm-build": "0.0.1"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/sahil9001/to-do-app.git"
},
"keywords": [
"todo",
"app"
],
"bugs": {
"url": "https://github.com/sahil9001/to-do-app/issues"
},
"homepage": "https://github.com/sahil9001/to-do-app#readme"
}
Whenever I run npm test it fails by saying no tests specified, how can I solve this issue? also whenever I try to use TRAVIS CI it fails to detect build script how can I create one?
Specify all required script in scripts property in package.json as below
{
"name": "to-do-app",
"version": "1.0.0",
"description": "A basic to-do app created using JavaScript.",
"main": "index.js",
"scripts": {
"test": "put test command here", // example "test": "mocha test.js"
"build" : "put build command here"
},
"author": "Sahil Silare",
"license": "MIT",
"dependencies": {
"body-parser": "^1.19.0",
"build": "^0.1.4",
"ejs": "^2.7.1",
"express": "^4.17.1",
"npm-build": "0.0.1"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/sahil9001/to-do-app.git"
},
"keywords": [
"todo",
"app"
],
"bugs": {
"url": "https://github.com/sahil9001/to-do-app/issues"
},
"homepage": "https://github.com/sahil9001/to-do-app#readme"
}
You don't have any scripts command listed in scripts property and have only default. You have to create and place it as per the need. Refer below links for more details
https://www.freecodecamp.org/news/introduction-to-npm-scripts-1dbb2ae01633/
https://flaviocopes.com/package-json/
If you look under "scripts" you'll see your npm scripts such as the script you call when you run "npm test"
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
The default value when you run NPM init is this simple echo saying no tests, you have to write your own test command(s) here.
Travis is failing to detect a build script, because you don't have a value for "build" in your scripts section, add something like:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "my_script_to_build"
},

How to fix "Npm ERR! JSON.parse Unexpected string in JSON at position 228.."

I am trying to start NPM after installing it but the start errors out.
I couldn't find syntactical errors in the 'package.json' file
I couldn't find the error log
I tried reinstalling
I tried clearing my cache
All without success
Here is my 'package.json' file:
{
"name": "git-test",
"version": "1.0.0",
"description": "test json file",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"lite-server": "^2.4.0"
},
"scripts": {
"start": "npm run lite"
"test": "echo \"Error: no test specified\" && exit 1"
"dev": "lite-server"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools.git"
},
"author": "Master-Hippo",
"license": "ISC",
"bugs": {
"url": "https://github.com/Master-Hippo/Front-
End_Web_UI_Frameworks_and_Tools/issues"
},
"homepage": "https://github.com/Master-Hippo/Front-
End_Web_UI_Frameworks_and_Tools#readme"
Here is the ERROR LOG in #bash:
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 228 while parsing
'{
npm ERR! JSON.parse "name": "git-test",
npm ERR! JSON.parse "version": "1.'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
And, although the message says an error log was created in a specific folder, none actually exists in said folder.
How can I resolve this issue?
Try validate your package.json with jsonlint
I guess that your file could be like this:
{
"name": "git-test",
"version": "1.0.0",
"description": "test json file",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"lite-server": "^2.4.0"
},
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "lite-server"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools.git"
},
"author": "Master-Hippo",
"license": "ISC",
"bugs": {
"url ": "https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools/issues"
},
"homepage": "https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools#readme"
}
Your package.json should be valid json like this:
{
"name": "git-test",
"version": "1.0.0",
"description": "test json file",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"lite-server": "^2.4.0"
},
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "lite-server"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools.git"
},
"author": "Master-Hippo",
"license": "ISC",
"bugs": {
"url": "https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools/issues"
},
"homepage": "https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools#readme"
}
There were a few commas missing.

Can't compile typescript from npm scripts

{
"name": "typescript-example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"compile": "./node_modules/.bin/tsc.cmd --outDir ./build --module commonjs ./src/*.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"typescript": "^3.0.1"
}
}
Project structure:
-project
-src
-main.ts
-node_modules
-.bin
-tsc
-tsc.cmd
-tsserver
-tsserver.cmd
-typescript
...
-package.json
-tsconfig.json
Command: npm run compile
Error: error TS6053: File 'src/*.ts' not found.
I don't want to install typescript globally.

Categories