npm ERR! code ELIFECYCLE module not found. What's wrong? - node.js

I'm pretty new to React and JavaScript, but I've been having a seriously frustrating issue. My NPM start command doesn't seem to work when I run it. I've tried to run npm install after deleting the node_modules folder, but I haven't had any luck. If anyone has a solution I would really appreciate the help.
See the error message below.
ass1#0.1.0 start C:\Users\Chris Conrad\Documents\_GIT\Udemy\React\Section 3 Understanding Base Features & Syntax\ass1
> react-scripts start
'Syntax\ass1\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:1032
throw err;
^
Error: Cannot find module 'C:\Users\Chris Conrad\Documents\_GIT\Udemy\React\react-scripts\bin\react-scripts.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
at Function.Module._load (internal/modules/cjs/loader.js:898: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! ass1#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ass1#0.1.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\Chris Conrad\AppData\Roaming\npm-cache\_logs\2020-05-21T00_32_03_270Z-debug.log
PS C:\Users\Chris Conrad\Documents\_GIT\Udemy\React\Section 3 Understanding Base Features & Syntax\ass1>
Below is my package.json
{
"name": "ass1",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.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"
]
}
}

Related

Postinstall of module is executed before postinstall of sub-module

Edit:
I'm asking how to install it from GitHub, not npm, that the question.
In case you want to know why: I'm working on some private projects and don't what t publish the code. This leads to the code being in a private repository, not published on npm.
Original post:
Trying to install a module from GitHub (it is in typescript, thus I need a compilation script [postinstall]). It seems to fail because one of the module dependencies is also on GitHub, and that postinstall script is not waited on by the current postinstall script.
Old GitHub issue that sounds related: https://github.com/npm/npm/issues/5001
Yes, like the issue, I also use the same dependency in the main project as the module does.
Program
Version
node
v16.1.0
npm
7.11.2
npm info run newton#1.0.1 postinstall node_modules/newton tsc -d -p .
npm info run nodemon#2.0.7 postinstall node_modules/nodemon node bin/postinstall || exit 0
npm info run rendery#2.0.0 postinstall node_modules/rendery tsc -d -p .
npm info run nodemon#2.0.7 postinstall { code: 0, signal: null }
npm timing build:run:postinstall:node_modules/nodemon Completed in 157ms
npm info run newton#1.0.1 postinstall { code: 0, signal: null }
npm timing build:run:postinstall:node_modules/newton Completed in 2409ms
npm info run rendery#2.0.0 postinstall { code: 2, signal: null }
npm timing reify:rollback:createSparse Completed in 2864ms
npm timing reify:rollback:retireShallow Completed in 0ms
npm timing command:install Completed in 47807ms
npm verb stack Error: command failed
npm verb stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\promise-spawn\index.js:64:27)
npm verb stack at ChildProcess.emit (node:events:365:28)
npm verb stack at maybeClose (node:internal/child_process:1067:16)
npm verb stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm verb pkgid rendery#2.0.0
npm verb cwd C:\Users\Elias\git\natrias
npm verb Windows_NT 10.0.19043
npm verb argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i" "--verbose" "--force"
npm verb node v16.1.0
npm verb npm v7.11.2
npm ERR! code 2
npm ERR! path C:\Users\Elias\git\natrias\node_modules\rendery
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c tsc -d -p .
npm ERR! src/2d/CanvasRenderyContext2D.ts(1,29): error TS2307: Cannot find module 'newton/2d/ReadonlyVector2' or its corresponding type declarations.
npm ERR! src/2d/CanvasRenderyContext2D.ts(2,21): error TS2307: Cannot find module 'newton/2d/Vector2' or its corresponding type declarations.
npm ERR! src/2d/ReadonlyRenderyContext2D.ts(1,29): error TS2307: Cannot find module 'newton/2d/ReadonlyVector2' or its corresponding type declarations.
npm ERR! src/2d/RenderyContext2D.ts(1,29): error TS2307: Cannot find module 'newton/2d/ReadonlyVector2' or its corresponding type declarations.
npm verb exit 2
npm timing npm Completed in 48318ms
npm verb code 2
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Elias\AppData\Local\npm-cache\_logs\2021-05-12T16_19_34_975Z-debug.log
Note that rendery postinstall starts before newton postinstall completes.
Newton package.json
{
"name": "newton",
"version": "1.0.1",
"description": "",
"scripts": {
"lint": "eslint '*/**/*.ts'",
"lint:fix": "eslint '*/**/*.ts' --fix",
"postinstall": "tsc -d -p .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^4.22.0",
"#typescript-eslint/parser": "^4.22.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0"
},
"dependencies": {
"typescript": "^4.2.4"
}
}
Rendery package.json
{
"name": "rendery",
"version": "2.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint '*/**/*.ts'",
"lint:fix": "eslint '*/**/*.ts' --fix",
"postinstall": "tsc -d -p ."
},
"keywords": [],
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^4.22.0",
"#typescript-eslint/parser": "^4.22.0",
"eslint": "^7.25.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-typescript-sort-keys": "^1.6.0"
},
"dependencies": {
"newton": "github:Elias-Graf/newton#main",
"typescript": "^4.2.4"
}
}
It's not a good practice to publish unbuilt packages. I recommend changing the postinstall script into a prepare script so it builds the package before publishing it.
{
"name": "newton",
"version": "1.0.1",
"description": "",
"scripts": {
"lint": "eslint '*/**/*.ts'",
"lint:fix": "eslint '*/**/*.ts' --fix",
"prepare": "tsc -d -p .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^4.22.0",
"#typescript-eslint/parser": "^4.22.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0"
},
"dependencies": {
"typescript": "^4.2.4"
}
}
{
"name": "rendery",
"version": "2.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint '*/**/*.ts'",
"lint:fix": "eslint '*/**/*.ts' --fix",
"prepare": "tsc -d -p ."
},
"keywords": [],
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^4.22.0",
"#typescript-eslint/parser": "^4.22.0",
"eslint": "^7.25.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-typescript-sort-keys": "^1.6.0"
},
"dependencies": {
"newton": "github:Elias-Graf/newton#main",
"typescript": "^4.2.4"
}
}
This would fix your issue.

how to fix this npm start not working ( after npx create-react-app )

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todos-clone-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todos-clone-app#0.1.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! /home/josh/.npm/_logs/2020-08-21T19_28_35_521Z-debug.log
Edit:
package.json
{
"name": "todos-clone-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.3",
"webpack-dev-server": "^3.11.0"
},
"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" ]
}
}
Try deleting your node_modules directory and package-lock.json file. Then run npm install.
In my case, it was because of not being in the right folder.
Generally, I create a folder and go to Vs code to open it for typing create-react-app "folder name" to the console.
The problem was I was trying to npm start in parent folder instead of "folder name".
All you have to do is:
cd folder_name
npm start
Try:
npx create-react-app ./
It worked for me.

NPM unable to find package.json file in React App

I've just gone to rerun my React app that I've been working on over the last few weeks and get this
C:\Users\matth\Documents\GitHub\LoveFoods-App>npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\matth\Documents\GitHub\LoveFoods-App\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\matth\Documents\GitHub\LoveFoods-App\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\matth\AppData\Roaming\npm-cache\_logs\2020-07-09T22_47_25_246Z-debug.log
Log for the error showing
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\matth\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start'
1 verbose cli ]
2 info using npm#6.14.5
3 info using node#v12.16.3
4 verbose stack Error: ENOENT: no such file or directory, open 'C:\Users\matth\Documents\GitHub\LoveFoods-App\package.json'
5 verbose cwd C:\Users\matth\Documents\GitHub\LoveFoods-App
6 verbose Windows_NT 10.0.18362
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\matth\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
8 verbose node v12.16.3
9 verbose npm v6.14.5
10 error code ENOENT
11 error syscall open
12 error path C:\Users\matth\Documents\GitHub\LoveFoods-App\package.json
13 error errno -4058
14 error enoent ENOENT: no such file or directory, open 'C:\Users\matth\Documents\GitHub\LoveFoods-App\package.json'
15 error enoent This is related to npm not being able to find a file.
16 verbose exit [ -4058, true ]
package.json as below
{
"name": "lovefoods-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"#auth0/auth0-react": "^1.0.0",
"#auth0/auth0-spa-js": "^1.10.0",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"firebase": "^7.15.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.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"
]
}
}
The thing is, that the package.json file is sitting in the folder and hasn't been moved at all since I last added to the application.
Anyone have any solutions that can help out at all? I've looked everywhere and can't seem to find anything that works.
Thanks!

React Electron ffmpeg-extract-frames build error

I am using the npm module ffmpeg-extract-frames for splitting video frames. It works completely fine when I am testing the module in a vanilla node environment. However, when I import the module in my Electron React desktop app component, it gives me a error when building.
This is how I am importing it:
const extractFrames = require("ffmpeg-extract-frames");
This is the error I am getting when building in my React Electron component:
> expedition-hacks-project#0.1.0 build /home/taylorallen/Desktop/expedition-hacks-project
> set "FLUENTFFMPEG_COV=false" && react-scripts build
Creating an optimized production build...
Failed to compile.
./node_modules/fluent-ffmpeg/index.js
Cannot find module: './lib-cov/fluent-ffmpeg'. Make sure this package is installed.
You can install this package by running: npm install ./lib-cov/fluent-ffmpeg.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! expedition-hacks-project#0.1.0 build: `set "FLUENTFFMPEG_COV=false" && react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the expedition-hacks-project#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! /home/taylorallen/.npm/_logs/2020-03-28T22_36_18_100Z-debug.log
My package.json:
{
"name": "expedition-hacks-project",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"bootstrap": "^4.4.1",
"bootstrap-fileinput": "^5.0.8",
"ffmpeg-extract-frames": "^2.0.2",
"fluent-ffmpeg": "^2.1.2",
"jquery": "^3.4.1",
"popper.js": "^1.16.1",
"react": "^16.13.1",
"react-bootstrap": "^1.0.0",
"react-dom": "^16.13.1",
"react-dropzone": "^10.2.2",
"react-icons": "^3.9.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1"
},
"homepage": "./",
"main": "src/main.js",
"scripts": {
"start": "react-scripts start",
"build": "set \"FLUENTFFMPEG_COV=false\" && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"electron": "electron ."
},
"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": {
"electron": "^8.2.0",
"electron-log": "^4.1.0",
"react-app-rewired": "^2.1.5"
}
}
I found a github issue https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/issues/573#issuecomment-305408048 addressing this error, and I set FLUENTFFMPEG_COV=0 on in my build script
My scripts:
"scripts": {
"start": "react-scripts start",
"build": "set \"FLUENTFFMPEG_COV=false\" && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"electron": "electron ."
},
Setting the env variable seems to not do anything, I still get the same error.

I can't get react up and running. When i type npm start then it gives me an error [duplicate]

This question already has answers here:
Start script missing error when running npm start
(33 answers)
Closed 3 years ago.
As you can see i get this error. Has it something to do with my package.json? Default looks like this.
{
"name": "reactproject",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.3.0"
}
}
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\k12\AppData\Roaming\npm-cache\_logs\2019-12-31T00_09_26_886Z-debug.log
PS C:\Users\k12\reactproject> ^C
After i did the command npm rm -g create-react-app i get the following in the command prompt
Error: EPERM: operation not permitted, mkdir 'C:\Users\k12'
TypeError: Cannot read property 'get' of undefined
at errorMessage (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-message.js:38:39)
at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:201:13)
at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20
at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:225:22)
at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:263:24
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:81:7
at Array.forEach (<anonymous>)
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:80:13
at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:171:20)
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:97
var doExit = npm.config.loaded ? npm.config.get('_exit') : true
^
TypeError: Cannot read property 'loaded' of undefined
at exit (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:97:27)
at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:216:3)
at process.emit (events.js:210:5)
at process._fatalException (internal/process/execution.js:150:25)
Install for [ 'create-react-app#latest' ] failed with code 7
C:\Users\k12>
The error is because you have no start script defined in your package.json
As I don't know what your server set up is, I cannot say what is should be exactly. But something along the lines of:
"scripts": {
"start": "node index.js",
}
Looking at your package.json, your project seems to be a Create React App project without a template. This occurs when you have an older, globally installed CRA on your machine. The default template package.json should look like this:
{
"name": "test3",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.3.2",
"#testing-library/user-event": "^7.1.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.3.0"
},
"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"
]
}
}
Remove the globally installed version (npm rm -g create-react-app) and try again with npx create-react-app reactproject
See the https://create-react-app.dev/docs/getting-started guide for more information.

Resources