I have checked both commands npm start and npm run start, both works perfectly. I used create-react-app. But to make configuration changes in the CSS module, I run npm eject but it throws an error.
But npm run eject worked? I'm confused on why npm eject didn't work. Can I configure this?
Below is my package.json:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
npm test, npm start, npm restart, and npm stop are all aliases for npm run xxx.
For all other scripts you define, you need to use the npm run xxx syntax.
See the docs at https://docs.npmjs.com/cli/run-script for more information.
npm start is the short form for npm run start. So, its one and the same thing.
One interesting thing to note is,
If the scripts object does not have a "start" property in package.json file, npm start or npm run start from command line will run node server.js by default.
But if the scripts object in package.json has "start" property, it overrides node server.js and executes the command in "start" property.
See - https://docs.npmjs.com/cli/v7/commands/npm-start#description
Telling this because sometimes this can be help to someone.
Inside the jenkins pipelines you should use npm commands with "run"
ex- npm run start
if not the command will not be executed.
Related
I am currently in the folder E:\Learn\app-code-vue
E:\Learn\app-code-vue>npm run dev
npm ERR! Missing script: "dev"
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! C:\Users\Shrikant Rana\AppData\Local\npm-cache\_logs\2022-01-24T14_
26_36_332Z-debug.log
See the scripts that are configured with Vue CLI 3 in the package.json file
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint" },
so you can run by use this : npm run serve
Check your package.json file and see if you have dev named in your "scripts" key. This is what your package.json script tag should look like if you want to run a dev command:
"scripts": {
"start": "node index.js",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
use npm run serve
It's working for me
You may need to check if you are really in the correct folder
Given a package.json that includes the following scripts:
"scripts": {
"dev": "npm install && webpack-dev-server --hot --progress --colors",
"build": "npm install && webpack --env.prod --progress --colors",
"start": "npm run dev"
}
Running npm start gives me many errors of the sort
`npm WARN tar ENOENT: no such file or directory, open 'C:\repos\my-project\node_modules\.staging\core-js-ea8988d1\client\shim.js'
followed by
npm ERR! code 1
npm ERR! Command failed: git submodule update -q --init --recursive
npm ERR! C:/Users/JohnDoe/AppData/Local/Programs/Git/mingw64/libexec/git-core\git-submodule: line 21: .: git-sh-setup: file not found
However, if instead I just run npm install directly, the npm installation of packages succeeds with no errors, and then I can run npm start thereafter with no issues. Why is this? There seems to be some kind of issue with including npm install in an npm script if the packages are not yet installed. I also tried setting start to "npm install" but running npm start gave me the same errors in that case.
I want to call multiple commands with the dev command. I found here that using concurrently is the best way to make this work since this would work on multiple OS.
How can I run multiple npm scripts in parallel?
I rand the folllwing aswell
npm install -g npm-windows-upgrade
npm install -g concurrently
npm install concurrently
I can run them individually. But when I run the script with npm run dev I get the following error. Why can't npm find those commands?
Terminal
[0] 'watch-client' is not recognized as an internal or external command,
[0] operable program or batch file.
[1] 'watch-server' is not recognized as an internal or external command,
[1] operable program or batch file.
[0] watch-client exited with code 1
--> Sending SIGTERM to other processes..
[1] watch-server exited with code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! diepio#1.0.0 dev: `concurrently --kill-others "watch-client" "watch-server"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the diepio#1.0.0 dev 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\31614\AppData\Roaming\npm-cache\_logs\2019-12-24T11_09_40_394Z-debug.log
Package.json
"scripts": {
"dev": "concurrently --kill-others \"watch-client\" \"watch-server\" \"serve\"",
"watch-client": "parcel ./src/client/index.html --open --out-dir ./builds/development/public",
"watch-server": "parcel ./src/server/index.ts --out-dir ./builds/development/private --target node",
"serve": "nodemon ./builds/development/private"
}
You may need to add npm and its submodules into your system PATH.
Have you downloaded the npm modules into your project directory?
You could also check that you have installed your npm submodules with the global argument.
The problem was that I was running the scripts in the wrong way I had to do it like this "dev": "concurrently --kill-others \"npm run watch-client\" \"npm run watch-server\" \"npm run serve\"",
When I tried to run npm run dev in my nuxt project, my console returned this message:
'nuxt' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! andromeda#1.0.0 dev: `nuxt`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the andromeda#1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I solved this problem.
I was looking in stackoverflow for similar problems and apparently the problem was the npm cache.
I will let a link bellow with the solution and a quick sample of what i did.
Link to the answer:
npm ERR! code ELIFECYCLE
Step 1: npm cache clean --force
Step 2: Delete node_modules by $ rm -rf node_modules folder or delete
it manually by going into the directory and right-click > delete.
Delete package-lock.json file too.
Step 3: npm install
To start again, npm start
Thanks everyone who take time to help, really appreciate.
Make sure nuxt is installed in your Nuxt project:
$ cd /path/to/nuxt-project
$ npm list nuxt
nuxt-project#1.0.0 /path/to/nuxt-project
└── nuxt#2.6.3
Here /path/to/nuxt-project contains your package.json and node-modules.
If it isn't installed, add nuxt to your project by doing:
$ npm install --save nuxt
Or put it in your project's package.json then do npm install:
"dependencies": {
"nuxt": "^2.0.0"
},
UPDATE:
If you are still getting "nuxt not recognized" problems, try to use explicit path to nuxt from your node_modules directory.
Given this directory (after doing npm install --save nuxt):
nuxt-project
|- node_modules
|- .bin
|- nuxt
|- package.json
Update the dev command in package.json with:
"scripts": {
"dev": "node_modules/.bin/nuxt"
},
Sometimes this blows up because you're not exporting node_modules/.bin directory.
Place or append the following line in your .bashrc or .zshrc:
export PATH=node_modules/.bin:$PATH
Have the same problem recently.
Solution for me was change the path of scripts section in package.json from this:
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
to that:
"scripts": {
"dev": "node_modules/.bin/nuxt",
"build": "node_modules/.bin/nuxt build",
"start": "node_modules/.bin/nuxt start",
"generate": "node_modules/.bin/nuxt generate"
},
Step 1: rm -rf node_modules package-lock.json
Step 2: npm cache clean --force
Step 3: npm install ( you may need to add --legacy-peer-deps or --force flag, if npm install is not working )
To start again, npm start
To make build, npm run build (ssr ) or generate ( csr )
Install globally cross-env:
npm install -g cross-env
Then just update package.json scripts to start with "cross-env ...."
example:
"scripts": {
"dev": "cross-env nuxt",
"build": "cross-env nuxt build",
"start": "cross-env nuxt start",
"generate": "cross-env nuxt generate",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore ."
},
This works on my Windows 10.
It simply means nuxt is not installed.
Try running npm install nuxt
I'm currently having problems starting NPM. I've installed along with Node.JS.
When I Run 'npm start' via Command Prompt I recieve the following ...
C:\Users\bobbyy>npm start
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\bobby\AppData\Roaming\npm-cache_logs\2017-03-29T21_36_56_974Z-debug.log
Can someone please advise what should be in 'package.json' start?
Write a code in package.json file as below
"scripts": {
"start": "node your-script.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
Copied from github forum
Hope It works for you.