How do I fix a missing script error and npm start? - reactjs

{
"name": "trelloclone-client",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/hlee686/TrelloClone-client.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/hlee686/TrelloClone-client/issues"
},
"homepage": "https://github.com/hlee686/TrelloClone-client#readme",
"dependencies": {
"dependencies": "0.0.1",
"node_module": "0.0.0",
"start": "^5.1.0"
},
"devDependencies": {},
"description": ""
}
When I npm start, I get an error as below.
Jakes-MacBook-Air:TrelloClone-client jslee$ npm start
trelloclone-client#1.0.0 start /Users/jslee/Desktop/TrelloClone-client
index.js
sh: index.js: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! trelloclone-client#1.0.0 start: index.js
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the trelloclone-client#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! /Users/jslee/.npm/_logs/2020-04-09T10_18_00_148Z-debug.log
How can I fix it and run npm start?
Thank you
The above is my package.json file.

Not too sure where to start, but do you have Node and Npm correctly installed and on your path? Try the below using terminal in the same folder as the package.json file.
node --version
npm --version
If the above return a version number, as least you know that node and npm are fine.
Have you installed the dependencies?
Finally, what's in the index.js file? Have you tried a simple 'hello world' type index.js just to make sure things hang together?

Related

Npm start is not working when trying to relaunch a react app

I've already launched the project using npx create-react-app. The app opened up in my browser and everything was going great. My computer restarted overnight, and the browser tab hosting the app was closed. I'm trying to re launch the app using "npm start" in the terminal, but I am getting the following error:
npm ERR! Missing script: "start"
npm ERR!
npm ERR! Did you mean one of these?
npm ERR! npm star # Mark your favorite packages
npm ERR! npm stars # View packages marked as favorites
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/guaclim/.npm/_logs/2023-01-31T15_34_16_068Z-debug-0.log
Npm start worked just fine when it came to launching the app the first time. I've tried updating and reinstalling npm. My json is also as it should be as far as I can tell :
"name": "new-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.16.5",
"#testing-library/react": "^13.4.0",
"#testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
I also attempted the following steps but it looks like there was an authorization issue:
npm install -g npm#latest -- to update npm because it is sometimes buggy.
rm -rf node_modules -- to remove the existing modules.
npm install -- to re-install the project dependencies.
The errors i got:
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! dest /usr/local/lib/node_modules/.npm-i9nnxROI
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR! [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/npm',
npm ERR! dest: '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

Why is npm start not working in react app?

I tried to run npm start to a React app that it was working perfectly, but now for some reason is not working. The mesage I recive is the following:
Error: Cannot find module 'C:\Users\albat\Desktop\personal_projects\alba_virtual_cv\index.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
at Function.Module._load (internal/modules/cjs/loader.js:686:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! alba_virtual_cv#1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the alba_virtual_cv#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\albat\AppData\Roaming\npm-cache\_logs\2020-05-11T09_08_43_976Z-debug.log
And my package.json is the following:
{
"name": "alba_virtual_cv",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"debug": "^4.1.1"
},
"devDependencies": {},
"description": ""
}
Please I need help to run the application again.
Thank you.
Run this before starting the project:
npm -i
This installs missing packages
It just means something went wrong when dependencies were installed the first time.
I suggest doing these three steps:
npm install -g npm#latest to update npm because it is sometimes buggy.
rm -rf node_modules to remove the existing modules.
npm install to re-install the project dependencies.
This should fix the problem.

after installing react-router-dom the web app shpws error in terminal on starting

I am trying to create reactjs apps and every time ,I install react-router-dom ,the web app shows error in terminal when I do npm start .
Here is the error
sh: 1: react-scripts: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! routeroute#0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the routeroute#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/rock/.npm/_logs/2019-03-16T10_04_47_549Z-debug.log
I tried doing rm -rf node_modules and then again installing but it doesn't seem to be working .
When I did npm install again ,
I got this error
npm ERR! path /home/rock/Desktop/routeroute/node_modules/browserslist/cli.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/home/rock/Desktop/routeroute/node_modules/browserslist/cli.js'
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! /home/rock/.npm/_logs/2019-03-16T10_19_02_250Z-debug.log
Here is the dependecies for package.json
{
"name": "routeroute",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-router-dom": "^4.4.0",
"react-scripts": "2.1.8"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
You need to update your version of npm:
Try with this command: npm i -g npm
Or you can use this: npm install npm#latest -g

Npm start error. React

I'm trying to do
npm start
In my react project but always have a problem
npm ERR! path /Users/dan/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/Users/dan/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and 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! /Users/dan/.npm/_logs/2018-04-11T17_50_33_041Z-debug.log
I've also know that 5 version of npm isn't the best. Because I've reinstall npm and now I've:
node -v
v8.11.1
npm -v
4.6.1
package.json
{
"name": "test",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.3.1",
"react-dom": "^16.3.1",
"react-scripts": "1.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
Try downgrade react-script
npm install react-scripts#2.1.8 --save
It's work for me!
Execute the following commands:
npx create-react-app myfirstreact
cd myfirstreact
npm start
It should work unless there are no files to work within the project.
Check if your react boilerplate template was fully generated by create-react-app otherwise you will need to upgrade your create-react-app
One way to know the template is not generated is if the src folder in your project directory does not exist.
your mistake is you are not in main file please run this command
cd-your file name

Can't install #uirouter/angularjs via npm

Trying to install #uirouter/angularjs via npm, but getting the following error:
npm ERR! code E404
npm ERR! 404 Not Found: #uirouter/angularjs#1.0.12
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/anatolyt/.npm/_logs/2018-01-10T14_14_22_375Z-debug.log
I'm using node v8.9.1 and npm 5.6.0, I'm using nvm too. Using OSX High Sierra - latest.
My package.json file is as following:
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"#uirouter/angularjs":"1.0.12"
},
"author": "",
"license": "ISC"
}
As I suspected it was related to our private npm repository - sinopia, it was unable to resolve name which begins from #, #uirouter/angularjs, #angular/core, etc...
Thanks for our IT guy, he found a solution in this thread: Unable to resolve dependencies like "#angular/common", you need to issue locally:
npm config set "#angular:registry" http://registry.npmjs.org/
it will cause npm to bypass sinopia and go straight to the npmjs repository for all packages within #angular scope. You have to perform same for every scope.
Another permanent solution (untested yet) is to modify sinopia's code:
in sinopia/lib/up-storage.js
change code on line number 10
var encode = function(thing) {
return encodeURIComponent(thing).replace(/^%40/, '#');
};

Resources