node start error in Windows - node.js

Windows MEVN stack project
i have npm start terminal output:
$ npm start
> nodejs-starter#1.0.0 start C:\final-dip\diplom-master
> SECRET=diplom nodemon index.js
"SECRET" is not internal or external
command, executable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nodejs-starter#1.0.0 start: `SECRET=diplom nodemon index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nodejs-starter#1.0.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\Admin\AppData\Roaming\npm-cache\_logs\2018-05-04T10_33_19_073Z-debug.log
code in package.json:
{
"name": "nodejs-starter",
"version": "1.0.0",
"description": "A boilerplate for NodeJS web servers",
"main": "index.js",
"scripts": {
"start": "SECRET=diplom nodemon index.js",
"init": "node ./controllers/init",
"debug": "cross-env PORT=3333 SECRET=GREEN_BUS nodemon --inspect index.js"
},
"keywords": [],
"author": "Almat Ybray",
"license": "MIT",
"devDependencies": {
"eslint": "^4.14.0",
"nodemon": "^1.14.7"
},
"dependencies": {
"async": "^2.6.0",
"body-parser": "^1.18.2",
"cookie-parser": "^1.4.3",
"cors": "^2.8.4",
"express": "^4.16.2",
"express-jwt": "^5.3.1",
"express-validator": "^5.0.3",
"helmet": "^3.9.0",
"jsonwebtoken": "^8.2.0",
"mongoose": "^5.0.0-rc1",
"morgan": "^1.9.0",
"multer": "^1.3.0",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"socket.io": "^2.0.4"
}
}

You're missing cross-env for your start script. Change your package.json to:
{
"scripts": {
"start": "cross-env SECRET=diplom nodemon index.js"
}
}
It's already being used in the debug script.
NOTE It's also not part of dependencies so it has to be added via npm i cross-env --save.

Related

heroku sh: 1: tsc: not found

this my scripts
{
"name": "fullstack-apollo-express-boilerplate-project",
"version": "1.0.0",
"description": "",
"main": "index.ts",
"scripts": {
"tsc": "./node_modules/typescript/bin/tsc",
"build": "rimraf ./build && tsc",
"dev": "nodemon",
"start": "npm run build && node build/index.js",
"codegen": "graphql-codegen --config ./codegen.yml",
"lint": "eslint . --ext .ts",
"lint-and-fix": "eslint . --ext .ts --fix",
"prettier-format": "prettier --config .prettierrc src/**/*.ts --write"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#graphql-codegen/cli": "^2.3.0",
"#graphql-codegen/typescript": "^2.4.1",
"#graphql-codegen/typescript-resolvers": "^2.4.2",
"#shopify/eslint-plugin": "^41.0.1",
"#types/bcryptjs": "^2.4.2",
"#types/cookie-parser": "^1.4.2",
"#types/mongoose-lean-virtuals": "^0.5.2",
"#types/nodemailer": "^6.4.4",
"#types/uuid": "^8.3.3",
"#typescript-eslint/eslint-plugin": "^5.5.0",
"#typescript-eslint/parser": "^5.5.0",
"eslint": "^8.4.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-prettier": "^4.0.0",
"nodemon": "^2.0.15",
"prettier": "^2.5.1",
"ts-node": "^10.4.0",
"typescript": "^4.5.2"
},
"dependencies": {
"#types/express": "^4.17.13",
"#types/node": "^16.11.11",
"apollo-server-core": "^3.5.0",
"apollo-server-express": "^3.5.0",
"bcryptjs": "^2.4.3",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"crypto-random-string": "3.3.1",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"express-openid-connect": "^2.5.1",
"graphql": "^16.0.1",
"graphql-fields-list": "^2.2.4",
"graphql-parse-resolve-info": "^4.12.0",
"graphql-voyager": "^1.0.0-rc.31",
"i": "^0.3.7",
"jsonwebtoken": "^8.5.1",
"moment": "^2.29.1",
"mongoose": "^6.0.14",
"mongoose-lean-virtuals": "^0.9.0",
"nodemailer": "^6.7.2",
"rimraf": "^3.0.2"
}
}
when i do deploy i get error
2022-01-14T08:20:20.950719+00:00 app[web.1]: sh: 1: tsc: not found
2022-01-14T08:20:20.956238+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2022-01-14T08:20:20.956684+00:00 app[web.1]: npm ERR! syscall spawn
2022-01-14T08:20:20.956866+00:00 app[web.1]: npm ERR! file sh
2022-01-14T08:20:20.956950+00:00 app[web.1]: npm ERR! errno ENOENT
2022-01-14T08:20:20.961092+00:00 app[web.1]: npm ERR! fullstack-apollo-express-boilerplate-project#1.0.0 build: `rimraf ./build && tsc`
2022-01-14T08:20:20.961191+00:00 app[web.1]: npm ERR! spawn ENOENT
2022-01-14T08:20:20.961291+00:00 app[web.1]: npm ERR!
2022-01-14T08:20:20.961337+00:00 app[web.1]: npm ERR! Failed at the fullstack-apollo-express-boilerplate-project#1.0.0 build script.
2022-01-14T08:20:20.961377+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-01-14T08:20:20.961191+00:00 app[web.1]: npm ERR! spawn ENOENT
2022-01-14T08:20:20.961291+00:00 app[web.1]: npm ERR!
2022-01-14T08:20:20.961337+00:00 app[web.1]: npm ERR! Failed at the fullstack-apollo-express-boilerplate-project#1.0.0 build script.
2022-01-14T08:20:20.961377+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I can't figure out what's the reason Everything works fine for me.
If you don't have a Procfile, Heroku will run your start script as a web process.
Your start script runs your build script, and your build script compiles your app using tsc:
"build": "rimraf ./build && tsc",
"start": "npm run build && node build/index.js",
// ^^^^^^^^^^^^^
This causes Heroku to try to compile your app every time your dyno starts, and since typescript is (correctly) a devDependency, tsc isn't available at runtime.
It doesn't make much sense to have your start script call your build script: your app only needs to be compiled once.
Modify your start script so it doesn't call your build script:
"build": "rimraf ./build && tsc",
"start": "node build/index.js",
Heroku automatically runs your build script at deploy time, and now it won't try to re-compile it at runtime.

How to fix NPM EJSONParse with this package.json file?

when I try the command npm install I have this
C:\Users\khaou>npm install
npm ERR! code EJSONPARSE
npm ERR! path C:\Users\khaou/package.json
npm ERR! JSON.parse Unexpected end of JSON input while parsing empty string
npm ERR! JSON.parse Failed to parse JSON data.
npm ERR! JSON.parse Note: package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\khaou\AppData\Local\npm-cache\_logs\2021-12-31T16_42_25_903Z-debug.log
This is the JSON:
{
"name": "eth-todo-list",
"version": "1.0.0",
"description": "Blockchain Todo List Powered By Ethereum",
"main": "truffle-config.js",
"directories": {
"test": "test"
},
"scripts": {
"dev": "lite-server",
"test": "echo \"Error: no test specified\" && sexit 1"
},
"author": "gregory#dappuniversity.com",
"license": "ISC",
"devDependencies": {
"bootstrap": "4.1.3",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"chai-bignumber": "^2.0.2",
"lite-server": "^2.3.0",
"nodemon": "^1.17.3",
"truffle": "5.0.2",
"truffle-contract": "3.0.6"
}
}
Probably your file association is other than JavaScript like JavaScript react or any other.
Check your package.json settings file to have Item:javascript Value:javascript as default extension (*) on Files:Associations.
package.json->file->preferences->settings->Files:Associations
Item:javascript Value:javascript
Hope it works!

Can't resolve dependency, refering to root project - next#"^9.5.6-canary.13, next-routes#"^1.4.2"

I am trying for hours to resolve this issue, running from one error to the next one…
Trying everything from --legacy-peer-deps, --force npm audit fix, at this point I am not even able to install my packages without running into errors, and I don't understand what that error is saying:
npm ERR! Found: next#9.5.6-canary.18
npm ERR! node_modules/next
npm ERR! next#"^9.5.6-canary.13" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer next#">=2" from next-routes#1.4.2
npm ERR! node_modules/next-routes
npm ERR! next-routes#"^1.4.2" from the root project
My package.json:
{
"name": "project-name",
"version": "0.1.0",
"private": true,
"main": "index.js",
"scripts": {
"test": "next dev",
"dev": "node server.js",
"build": "next build",
"start": "next start"
},
"dependencies": {
"#apollo/client": "^3.3.19",
"apollo-boost": "^0.4.9",
"babel-loader": "^8.2.2",
"babel-register": "^6.26.0",
"dotenv": "^8.2.0",
"framer-motion": "^4.0.0",
"fs": "0.0.1-security",
"graphql": "^15.5.0",
"https": "^1.0.0",
"ignore-loader": "^0.1.2",
"lazysizes": "^5.3.2",
"next": "^9.5.6-canary.13",
"next-routes": "^1.4.2",
"node-webvtt": "^1.9.3",
"path": "^0.12.7",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"sass": "^1.32.6",
"storyblok-js-client": "^4.0.5",
"url": "^0.11.0"
},
"devDependencies": {
"#babel/register": "^7.12.13",
"#types/node": "^14.14.37",
"#types/react": "^17.0.3",
"dotenv-webpack": "^6.0.0",
"typescript": "^4.2.4"
}
}
I am guessing some of the longer list of packages are not playing along with each other, but how can I investigate this further? The error is not very helpful. Also the similar combinations of packages and version seem to work fine in other projects …
The error originally complained about graphql packages I am using, after updating some versions it is now complaining about the next and next-routes packages …
Any ideas?

npm err! code 1 when performing npm install

I have looked at the other posts concerning other people who had this or similar problems and those fixes don't seem to be working for me. When I run "npm install" I constantly get the line "npm ERR! code 1"
This is preventing me form getting to test my code as I can't install my node modules.
Here is part the output:
npm ERR! code 1
npm ERR! path /Users/myname/Documents/blip/blip-api-billbot/node_modules/mongodb-client-encryption
npm ERR! command failed
npm ERR! command sh -c prebuild-install --tag-prefix node-v || node-gyp rebuild
The package.json file:
{
"name": "blip-api-billbot",
"version": "1.0.0",
"description": "Blip's billbot architecture for creating links to biller accounts.",
"main": "chrome-script.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"linuxRebuild": "docker run --rm -v '$PWD':/var/task lambci/lambda:build-nodejs12.x npm rebuild"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#babel/runtime": "^7.12.13",
"aws-sdk": "^2.824.0",
"axios": "^0.21.0",
"axios-cookiejar-support": "^1.0.1",
"base-64": "^1.0.0",
"bindings": "^1.5.0",
"cheerio": "^1.0.0-rc.5",
"chrome-aws-lambda": "^5.5.0",
"dotenv": "^8.2.0",
"fs-extra": "^9.0.1",
"glob": "^7.1.6",
"lambda-packager": "^0.2.1",
"mongodb": "^3.6.3",
"mongodb-client-encryption": "^1.1.0",
"node-downloader-helper": "^1.0.15",
"node-fetch": "^2.6.1",
"puppeteer": "^2.1.1",
"puppeteer-extra": "^3.1.15",
"puppeteer-extra-plugin-adblocker": "^2.11.9",
"puppeteer-extra-plugin-repl": "^2.2.8",
"puppeteer-extra-plugin-stealth": "^2.6.5",
"qs": "^6.9.4",
"rimraf": "^3.0.2",
"serverless-docker-artifacts": "^0.1.1",
"serverless-dotenv-plugin": "^3.1.0",
"serverless-offline": "^5.12.1",
"serverless-plugin-scripts": "^1.0.2",
"tough-cookie": "^4.0.0",
"uuid": "^8.3.2",
"uuid-mongodb": "^2.4.1"
}
}

npm run start with "DEBUG=*" issue on Windows

{
"name": "apokidsi",
"version": "0.717",
"contributors": [
],
"dependencies": {
"angular": "1.5.8",
"angular-cookies": "1.5.8",
"angular-messages": "1.5.8",
"angular-ui-router": "1.0.0-beta.3",
"debug": "^3.0.0",
"flag-icon-css": "2.8.0",
"jquery": "3.2.1",
"moment": "2.18.1",
"moment-timezone": "0.5.13",
"node-fetch-npm": "^2.0.1"
},
"scripts": {
"clean": "gulp clean",
"start": "DEBUG=true HOST=localhost:4200 gulp server",
}
}
Here is the package.json file.
When I run npm run start
I get this message
'DEBUG' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
After checking all the possibilities we have to use the cross-env dependencies.
so install npm install cross-env --save-dev
and in package.json
"Start": " cross-env-shell DEBUG=True HOST=dev.example.com gulp server"

Resources