nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.48k stars 284 forks source link

Script error- Unable to start my repo #3370

Closed Rajshah1897 closed 7 months ago

Rajshah1897 commented 3 years ago

Please help me resolve as below error

**I already tried npm install and npm start but still not working

also added in package.json file in scripts { "start": "node index.js",** }

npm ERR! missing script: start

logs 0 info it worked if it ends with ok 1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ] 2 info using npm@6.13.4 3 info using node@v10.18.0 4 verbose stack Error: missing script: start 4 verbose stack at run (/usr/local/lib/node_modules/npm/lib/run-script.js:155:19) 4 verbose stack at /usr/local/lib/node_modules/npm/lib/run-script.js:63:5 4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:116:5 4 verbose stack at /usr/local/lib/node_modules/npm/nodemodules/read-package-json/read-json.js:436:5 4 verbose stack at checkBinReferences (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:391:45) 4 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:434:3) 4 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:161:5) 4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:382:12 4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:115:16 4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3) 6 verbose Darwin 19.6.0 7 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" 8 verbose node v10.18.0 9 verbose npm v6.13.4 10 error missing script: start 11 verbose exit [ 1, true ]

Ayase-252 commented 3 years ago

Could you post your package.json, if possible?

Rajshah1897 commented 3 years ago

@Ayase-252 here it is { "version": "1.21.0", "private": true, "workspaces": [ "packages/*" ], "scripts": { "test": "lerna run test", "new-version": "lerna version --conventional-commits --yes", "watch": "lerna run watch", "watch:dev": "NODE_ENV=development lerna run watch", "diff": "lerna diff", "changed": "lerna changed", "global-install": "cd ./scripts && ./npm-helper.sh i", "global-build": "cd ./scripts && ./build-helper.sh", "global-install:ci": "cd ./scripts && ./npm-helper.sh ci", "info": "lerna info", "commit": "git add . && npx git-cz", "lerna-publish": "lerna publish --exact", "chromatic": "npx chromatic --project-token 4026iz09kt3", "chromatic:build": "npm run chromatic --project-token 4026iz09kt3 || true", "storybook": "start-storybook -s ./storybook-static/assets -p 6006", "build-storybook": "build-storybook", "pipeline-pr-build": "npx lerna run pipe-line-build", "pipe-line-build": "npx lerna run pipe-line-build" }, "dependencies": { "lerna": "3.21.0", "notistack": "1.0.5", "react": "17.0.1", "react-dom": "17.0.1", "react-hook-form": "6.15.1", "react-select": "4.1.0", "storybook": "6.1.15", "webpack": "4.41.5" }, "devDependencies": { "@babel/core": "7.14.2", "@cypress/eslint-plugin-dev": "5.0.0", "@material-ui/core": "^4.11.0", "@material-ui/lab": "^4.0.0-alpha.56", "@storybook/addon-actions": "^6.0.22", "@storybook/addon-backgrounds": "^6.0.22", "@storybook/addon-essentials": "^6.0.22", "@storybook/addon-links": "^6.0.22", "@storybook/react": "^6.0.22", "addon-redux": "1.1.0", "babel-loader": "^8.1.0", "babel-preset-react-app": "^9.1.2", "chromatic": "^5.2.0", "commitizen": "4.2.4", "core-js": "3.12.1", "cz-conventional-changelog": "3.2.0", "eslint": "7.0.0", "eslint-loader": "^4.0.2", "eslint-plugin-chai-friendly": "0.5.0", "eslint-plugin-cypress": "2.10.3", "eslint-plugin-react": "7.20.0", "eslint-plugin-react-hooks": "4.0.2", "extract-text-webpack-plugin": "^3.0.2", "husky": "^4.2.5", "optimize-css-assets-webpack-plugin": "^5.0.4", "postcss-safe-parser": "^5.0.1", "pre-push": "0.1.1", "react-dev-utils": "^10.2.1", "react-is": "^16.13.1", "storybook-loader": "^0.1.4", "stylelint": "^13.6.1", "stylelint-config-standard": "^20.0.0", "stylelint-scss": "^3.18.0", "terser-webpack-plugin": "^4.2.2", "webpack-bundle-analyzer": "^3.9.0", "yup": "0.29.0" }, "husky": { "hooks": { "pre-push": "npx lerna run prepush --since dev", "prepare-commit-msg": "exec < /dev/tty && git cz --hook || true" } }, "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog" } } }

Ayase-252 commented 3 years ago

How about adding a start in scripts, then run npm run start?

--- a.json      2021-05-14 13:28:25.000000000 +0800
+++ b.json      2021-05-14 13:29:01.000000000 +0800
@@ -17,6 +17,7 @@
     "storybook": "start-storybook -s ./storybook-static/assets -p 6006",
     "build-storybook": "build-storybook",
     "pipeline-pr-build": "npx lerna run pipe-line-build",
-    "pipe-line-build": "npx lerna run pipe-line-build"
+    "pipe-line-build": "npx lerna run pipe-line-build",
+    "start": "node index.js"
   }
 }
Rajshah1897 commented 3 years ago

@Ayase-252 No it is not working as I mentioned above Same error script missing

Ayase-252 commented 3 years ago

emm... It's weird....

Can you confirm you execute command in right directory?

Rajshah1897 commented 3 years ago

@Ayase-252 Yes I executed in correct directory. Npm install and Npm start

Rajshah1897 commented 3 years ago

Why it's script missing error? What I am missing?

Ayase-252 commented 3 years ago

I'm also confused. The error indicates that there is no start field in scripts in package.json

I've suggested that to add start. Therefore, I'm out of idea about the issue....

sharmankita commented 3 years ago

@Ayase-252 here it is { "version": "1.21.0", "private": true, "workspaces": [ "packages/*" ], "scripts": { "test": "lerna run test", "new-version": "lerna version --conventional-commits --yes", "watch": "lerna run watch", "watch:dev": "NODE_ENV=development lerna run watch", "diff": "lerna diff", "changed": "lerna changed", "global-install": "cd ./scripts && ./npm-helper.sh i", "global-build": "cd ./scripts && ./build-helper.sh", "global-install:ci": "cd ./scripts && ./npm-helper.sh ci", "info": "lerna info", "commit": "git add . && npx git-cz", "lerna-publish": "lerna publish --exact", "chromatic": "npx chromatic --project-token 4026iz09kt3", "chromatic:build": "npm run chromatic --project-token 4026iz09kt3 || true", "storybook": "start-storybook -s ./storybook-static/assets -p 6006", "build-storybook": "build-storybook", "pipeline-pr-build": "npx lerna run pipe-line-build", "pipe-line-build": "npx lerna run pipe-line-build" }, "dependencies": { "lerna": "3.21.0", "notistack": "1.0.5", "react": "17.0.1", "react-dom": "17.0.1", "react-hook-form": "6.15.1", "react-select": "4.1.0", "storybook": "6.1.15", "webpack": "4.41.5" }, "devDependencies": { "@babel/core": "7.14.2", "@cypress/eslint-plugin-dev": "5.0.0", "@material-ui/core": "^4.11.0", "@material-ui/lab": "^4.0.0-alpha.56", "@storybook/addon-actions": "^6.0.22", "@storybook/addon-backgrounds": "^6.0.22", "@storybook/addon-essentials": "^6.0.22", "@storybook/addon-links": "^6.0.22", "@storybook/react": "^6.0.22", "addon-redux": "1.1.0", "babel-loader": "^8.1.0", "babel-preset-react-app": "^9.1.2", "chromatic": "^5.2.0", "commitizen": "4.2.4", "core-js": "3.12.1", "cz-conventional-changelog": "3.2.0", "eslint": "7.0.0", "eslint-loader": "^4.0.2", "eslint-plugin-chai-friendly": "0.5.0", "eslint-plugin-cypress": "2.10.3", "eslint-plugin-react": "7.20.0", "eslint-plugin-react-hooks": "4.0.2", "extract-text-webpack-plugin": "^3.0.2", "husky": "^4.2.5", "optimize-css-assets-webpack-plugin": "^5.0.4", "postcss-safe-parser": "^5.0.1", "pre-push": "0.1.1", "react-dev-utils": "^10.2.1", "react-is": "^16.13.1", "storybook-loader": "^0.1.4", "stylelint": "^13.6.1", "stylelint-config-standard": "^20.0.0", "stylelint-scss": "^3.18.0", "terser-webpack-plugin": "^4.2.2", "webpack-bundle-analyzer": "^3.9.0", "yup": "0.29.0" }, "husky": { "hooks": { "pre-push": "npx lerna run prepush --since dev", "prepare-commit-msg": "exec < /dev/tty && git cz --hook || true" } }, "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog" } } }

@Rajshah1897 If you are using this package.json. Then it's clear that you have missed the "start" in scripts section. And if you don't add start and try running "npm start" it will search for "server.js" and when not found it will throw this error. And I am assumming you main file is index.js here, Please correct me If I am wrong? If So the as @Ayase-252 also suggested add "start": "node index.js" this and try running.

Rajshah1897 commented 3 years ago

So what would be my next step?

Ayase-252 commented 3 years ago

Again, I'd suggest to add "start": "node index.js" in scripts section in your package.json. Double check that field exists in package.json before run npm run start, then run it.

RedYetiDev commented 7 months ago

@Ayase-252 seemed to provide several solution steps, and with no response, I'm assuming this issue is resolved. If you disagree, please followup with a member of the Node.js team.

Thank you!