Why does "npm start" give me error when i try run my app? - node.js

i dont understand why i got this error every
time when i try run "npm start".
> # start E:\ReactNative\navigation_app
> expo start
internal/modules/cjs/loader.js:895
throw err;
^
Error: Cannot find module 'C:\Users\Roei\AppData\Roaming\npm\node_modules\expo-cli\bin\expo.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:892:15)
at Function.Module._load (internal/modules/cjs/loader.js:785:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:1143:12)
at internal/main/run_main_module.js:16:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # start: `expo start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # 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\Roei\AppData\Roaming\npm-cache\_logs\2019-11-16T17_19_40_408Z-debug.log
this is my package.json and try
to figure out whats wrong there
{
"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": {
"expo": "^35.0.0",
"expo-font": "^7.0.0",
"react": "16.8.3",
"react-dom": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
"react-native-web": "^0.11.7"
},
"devDependencies": {
"babel-preset-expo": "^7.1.0"
},
"private": true
}
i would like to solve that issue and to understand whats worng .

You need to install expo-cli globally npm i -g expo-cli

you need to install Expo. Run an npm install or install expo globally

You don't have Expo-CLI installed globally, that is why you are getting the error at your local project. It needs Expo module to work, but can't find it. So run npm install -g expo-cli as it has been said, if it does not install paste the error code here.

Related

Node.js Cannot Find Module error on npm start

I am getting an error like the below when I run npm start command to start the server for my first react project. I have tried uninstalling and reinstalling the node.js but did not work. How can I resolve this issue? I am including my package.json and my directory structure over here.
This is the error:
> reactproject1#1.0.0 start C:\Users\LENOVO\reactproject1
> node index.js
internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module 'C:\Users\LENOVO\reactproject1\index.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactproject1#1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactproject1#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\LENOVO\AppData\Roaming\npm-cache\_logs\2020-07-18T09_12_04_972Z-debug.log
This is my package.json file of my react project. I have edited it by adding "start":"node index.js".
{
"name": "reactproject1",
"version": "1.0.0",
"description": "restropart",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1"
}
}
My Directory tree is as follows
-ReactProject
-node_modules
-public
-src
->index.js
-package.json
-package-lock.json
My index.js file resides inside the src folder. The node_modules, public, src, package.json and package-lock.json files are on the same line.
The start script refers to index.js, but you don't have such a file - it's under src/index.js. You could either move it to the project root, or update the start script accordingly:
"scripts": {
"start": "node src/index.js"
},

npm ERR! code ELIFECYCLE is being displayed while running "npn start" on window command line for the following package.json file

I am learning full stack web development with Angular and new to web deployment.I am unable to guess the reason behind this npm ERR! code ELIFECYCLE; displayed while running "npn start" on window command line for the following package.json file. I am stuck here and not much help available on google or I am unable to search right answer because of lack of proper keyword required to search the answer.
{
"name": "confusion",
"version": "1.0.0",
"description": "This is a website for Ristorante Con Fusion",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "npm run watch:all",
"lite": "lite-server",
"scss": "node-sass -o css/ css/",
"watch:scss": "onchange \"css/*.scss\" -- npm run scss",
"watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\""
},
"author": "Imtiaz",
"license": "ISC",
"devDependencies": {
"lite-server": "^2.3.0",
"node-sass": "^4.13.1",
"onchange": "^3.3.0",
"parallelshell": "^3.0.2"
},
"dependencies": {
"bootstrap": "^4.0.0",
"bootstrap-icons": "^1.0.0-alpha2",
"bootstrap-social": "^5.1.1",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
"popper.js": "^1.12.9"
}
}
OutPut:
C:\Users\NEW WS-08\Bootstrap4\conFusion>npm start
> confusion#1.0.0 start C:\Users\NEW WS-08\Bootstrap4\conFusion
> npm run watch:all
> confusion#1.0.0 watch:all C:\Users\NEW WS-08\Bootstrap4\conFusion
> parallelshell "npm run watch:scss" "npm run lite"
child_process.js:422
throw new ERR_INVALID_ARG_TYPE('options.cwd', 'string', options.cwd);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "options.cwd" property must be of type str
ing. Received type function
←[90m at normalizeSpawnArguments (child_process.js:422:11)←[39m
←[90m at spawn (child_process.js:534:16)←[39m
at C:\Users\NEW WS-08\Bootstrap4\conFusion\node_modules\←[4mparallelshell←[2
4m\index.js:104:17
at Array.forEach (<anonymous>)
at Object.<anonymous> (C:\Users\NEW WS-08\Bootstrap4\conFusion\node_modules\
←[4mparallelshell←[24m\index.js:100:6)
←[90m at Module._compile (internal/modules/cjs/loader.js:955:30)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10
)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:811:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:723:14)←[39m
←[90m at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)←[39
m {
code: ←[32m'ERR_INVALID_ARG_TYPE'←[39m
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! confusion#1.0.0 watch:all: `parallelshell "npm run watch:scss" "npm run
lite"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the confusion#1.0.0 watch:all script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\NEW WS-08\AppData\Roaming\npm-cache\_logs\2020-03-26T08_26
_18_785Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! confusion#1.0.0 start: `npm run watch:all`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the confusion#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\NEW WS-08\AppData\Roaming\npm-cache\_logs\2020-03-26T08_26
_18_841Z-debug.log
This is a common issue can not be fixed using npm audit fix. All you can do is to copy the actual index.js file of parallelshell into your node_modules directory.
So to do it below are the instructions:
1. Go to https://raw.githubusercontent.com/darkguy2008/parallelshell/master/index.js
2. Copy the content here.
3. Now go to the directory of your project, it may be something like /project/node_modules/parallelshell/index.js
4. Inside the index.js replace the contents with the one you copied from the link in Step 1.
5. Save the file and exit.
Hope this fix will work for you.

Unable to deploy application on heroku

I am receiving the following error while deploying my application on heroku, I have deployed it before with no problems. I also have not changed the package.json file, so I am unsure why I am getting the following error.
There are no additional configs for heroku, the application was previously deployed, and cannot be updated.
The application is deployed currently under a previous version through the heroku website from my github.
Any help to resolve this issue would be greatly appreciated!
error from heroku
-----> Build
Running heroku-postbuild
> operations-reporting#1.0.0 heroku-postbuild /tmp/build_04594e22478b41fb98f830b9b12c2400
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
added 86 packages from 287 contributors and audited 906755 packages in 16.658s
found 2 moderate severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
> client#0.1.0 build /tmp/build_04594e22478b41fb98f830b9b12c2400/client
> react-scripts build
internal/modules/cjs/loader.js:800
throw err;
^
Error: Cannot find module 'es-abstract/2019/CreateDataProperty'
Require stack:
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/implementation.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/index.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/util.promisify/implementation.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/util.promisify/index.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/html-webpack-plugin/index.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/react-scripts/config/webpack.config.js
- /tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/react-scripts/scripts/build.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/implementation.js:3:26)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/implementation.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/object.getownpropertydescriptors/index.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/util.promisify/implementation.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/util.promisify/index.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/html-webpack-plugin/index.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/react-scripts/config/webpack.config.js',
'/tmp/build_04594e22478b41fb98f830b9b12c2400/client/node_modules/react-scripts/scripts/build.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client#0.1.0 build 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! /tmp/npmcache.PQkmQ/_logs/2019-12-14T21_42_39_533Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! operations-reporting#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the operations-reporting#1.0.0 heroku-postbuild 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! /tmp/npmcache.PQkmQ/_logs/2019-12-14T21_42_39_547Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- node_modules checked into source control
https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
package.json
{
"name": "client",
"version": "0.1.0",
"main": "index.js",
"private": true,
"dependencies": {
"axios": "^0.19.0",
"config": "^3.2.4",
"express": "^4.17.1",
"express-validator": "^6.3.0",
"formik": "^2.0.6",
"mongoose": "^5.7.12",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.2.0",
"react-table": "^6.10.3",
"reactstrap": "^8.1.1",
"schema-utils": "^2.6.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"concurrently": "^5.0.0",
"nodemon": "^2.0.1"
},
"proxy": "http://localhost:5000"
}
Find the missing module and update your package like so:
npm install --save --save-exact foo#1.2.3
This is from heroku
Other solution:
heroku config:set NODE_MODULES_CACHE=false

Gatsby’s Environmental Variables "env.cmd not found"

Trying to run env.cmd with Gatsby but I'm getting sh: env-cmd not found. I do have installed the package. I have tried deleting .node-modules and running npm install but I'm still getting the same error.
gatsby-config.js:
{
...
"scripts": {
"build": "gatsby build",
"develop": "env-cmd --file .env.development --fallback gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
"start": "npm run develop",
"serve": "gatsby serve",
"clean": "gatsby clean",
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
},
"dependencies": {
"gatsby": "^2.18.12",
"gatsby-plugin-sass": "^2.1.26",
"node-sass": "^4.13.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"typescript": "^3.7.4"
},
"devDependencies": {
"env-cmd": "^8.0.2",
"prettier": "^1.19.1"
},
...
}
Terminal:
npm run develop
> gatsby-starter-hello-world#0.1.0 develop /Users/renatognunes/Documents/Studies 1:4/Gatsby/gatsby-site
> env-cmd --file .env.development --fallback gatsby develop
sh: env-cmd: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! gatsby-starter-hello-world#0.1.0 develop: `env-cmd --file .env.development --fallback gatsby develop`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the gatsby-starter-hello-world#0.1.0 develop script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
UPDATE
For anyone else running into the same issue, here is the solution I found that worked for me: https://stackoverflow.com/a/56367980/10225590
Changing my npm version to v16.3.1 from v14.18.3 fixed this for me

sh: react-scripts-start: command not found

I have a project that I cannot run npm start on.
I haven't touched this project in two weeks. The only thing I did yesterday was add a git repository, that's it.
When I tried to run npm start I got this error:
sh: react-scripts-start: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! bk-react-replica#0.1.0 start: 'react-scripts-start'
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the bk-react-replica#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I've looked at the solutions on other posts about this same error but none work for me. I've deleted the node_modules directory and package-lock.json files, then ran npm install.
However, I still get the same error message. Does anyone know what's wrong?
This is my package.json file:
{
"name": "bk-react-replica",
"version": "0.1.0",
"private": true,
"homepage": "http://qhafeezdomain.dreamhosters.com/projects/bkreplica",
"dependencies": {
"antd": "^3.3.0",
"normalize.css": "^8.0.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-native-scripts": "^1.13.1",
"react-redux": "^5.0.7",
"react-router-dom": "^4.2.2",
"react-scripts": "^1.1.4",
"react-scripts-cssmodules": "^1.0.171",
"redux": "^3.7.2"
},
"scripts": {
"start": "react-scripts-start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
As I will reference you to an answer I provided to a question similar to yours, run this:
npm i -g npm //which will update npm
rm -rf node_modules/ && npm cache clean // to remove the existing modules and clean the cache.
npm install //to re-install the project dependencies.
Edited:
I just noticed your package.json it should be:
"scripts": {
"start": "react-scripts start",
not
"scripts": {
"start": "react-scripts-start",

Resources