I'm making a webpack manually.
I created a package.json file with "npm init" in an empty folder.
However, because debug is floating, I keep getting errors that I don't know in English. Is this dubug the problem? And can you get rid of it??
/////////package.json file ///////////////////
enter image description here
////////error code////////////////
found 0 vulnerabilities
PS C:\Users\정승민\Desktop\제로초React마지막> npm run dev
npm ERR! missing script: dev
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\정승민\AppData\Roaming\npm-cache_logs\2020-09-17T15_19_19_771Z-debug.log
Oh, and no one is helping me because I was first asking a question.
Please let me know if you have any problems.
I think it happens because of two reasons,first you should go to this path
C:\Users(your name of system)\AppData\Roaming\npm and clear npm and npm-cache,if it doesn't work please go to Control Panel>System and Security>System>Advance system setting>Enviroment variable and set system variables path C:\Windows\System32\ variable and restart your System and then try it.
npm run dev
You ran this command, but the "dev" script is not in your package.json file.
You can add a "dev" script by changing your package.json file to be like the example below.
{
"name": "lecture",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "echo This is the \"dev\" script running!",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "min",
"license": "MIT"
}
Running npm run dev will now output: This is the "dev" script running!
Related
I am trying to run a React script for game and I have been following a tutorial online ( I am very new to all programming). Every time I try to run some code to work on port 8000 I get this that pops up:
Debugger attached.
Lifecycle scripts included in server#1.0.0:
test
echo "Error: no test specified" && exit 1
Waiting for the debugger to disconnect...
This is my package.json file
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "app.js",
"dependencies": {
"express": "4.17.1",
"socket.io": "2.3.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
I run it in the terminal through npm run.
I have tried other resolves on other questions I have found like Jest or Mocha and none of that has worked.
Thank you for your help:)
When you execute npm run, you have to specify the script you want to run from the scripts section(i.e. npm run test).
According to your problem, I think when you didn't put the script name and just run npm run, it might have run the first script under the scripts section of package.json(If you want, you can specifically run that command using npm run test).
So if you want to run a node server you can set up a script in the package.json as follows
{
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
}
You may change the file name if you have used a different name than the server.js.
Then You can run the above script using npm run start.
If you want to run a react script, you can do the same thing as follows.
{
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"do": "react-scripts <script_name>"
},
}
and npm run do.
Please note that in order to run the above command you have to install necessary packages such as react, react-scripts, etc...
For more info on react-scripts, please checkout here!
Problem
I am trying to put my React app on github pages. However, I can't even deploy the app to GitHub pages.
My Setup
I am using Visual Studio Code on my Windows 10 machine. I created my React app with create-react-app. I followed this tutorial to set up my app for Github Pages. This is my package.json:
{
"homepage": "https://MisturDust319.github.io/ign_code_foo",
"name": "ign_code_foo",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"bootstrap": "^4.1.0",
"gh-pages": "^1.1.0",
"react": "^16.3.1",
"react-dom": "^16.3.1",
"react-scripts": "1.1.4",
"reactstrap": "^5.0.0-beta.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy:": "gh-pages -d build"
},
"devDependencies": {}
}
The full source is available here
What I've Done
To deploy, you are supposed to just run
npm run deploy
However, when I enter that command, from Windows PowerShell, Git Bash, and the Command Prompt, I just get several variations of "command not found".
In response, I uninstalled gh-pages from dev-dependencies and reinstalled it as a normal dependency. No change. At this point, I've exhausted all solutions I can think of, and Google has only pulled up people who didn't include the deploy command in package.json.
You need to install gh-pages globally by adding "-g":
npm install -g gh-pages --save-dev
and then
npm run deploy
Docs: https://docs.npmjs.com/downloading-and-installing-packages-globally
You need install gh-pages before running deploy, run:
npm install --save-dev gh-pages
then
npm run deploy
I cannot add a comment to this post, because I don't have enough score. But there is an error in the your package.json code:
"deploy:": "gh-pages -d build"
Because, there is an extra semicolon :. It should be:
"deploy": "gh-pages -d build"
Little explanation about why this issue is happening ,followed by the fix of this issue
In package.json file
"devDependencies": {
"gh": "^2.8.6",
"pages": "0.0.16"
}
gets created when we run npm install gh pages —save-dev
but to deploy our project when we run npm run deploy that time it checks in package.json file against deploy which script is mentioned
Since in package.json
"scripts": {
"deploy": "gh-pages -d build",
....}
gh-pages -d build script is mentioned.
It will try to perform this operation but the reason its throwing error like this( if you are mac user) on npm run deploy
sh: gh-pages: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! basic#0.1.0 deploy: `gh-pages -d build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the basic#0.1.0 deploy script.
is because gh-pages also need to be installed globally as well.
So if you run npm install -g gh-pages --save-dev
Issue which you're getting related to gh-pages installation will get resolved.
Might be a path problem, it's a usual case for Windows users that try to use cmd instead of *nix terminal. Try to exit and enter cmd if you didn't yet. After that you should ensure that it can access gh-pages package.
Also you might look on answers to a similar question. And ensure that your git version is >= 1.9 as it's told in requirements.
I had copied items into the wrong section. In my case my dependencies are above the scripts and I had put two scripts in the dependencies section like a money. Moving them into the right place resolved the issue for me.
Tip: make sure your script are not placed in the wrong section.
Very, very likely you don't have git added to your Path variable
If running git in your CMD results in an error - this is the issue.
Add git.exe and other binaries to your path, usually it C:\Program Files\Git\bin and try again running gh-pages -d build
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/, '#');
};
I am trying to pick up angularjs v2 using the official documentation provided.
I followed the instructions on this page.
https://angular.io/docs/ts/latest/guide/setup.html
After I run npm start, I see a webpage http://localhost:3000/ being launched automatically on my default browser.
I see several js files in the quickstart folder. Which are the js files that are being run and in what sequence? Is there a main file that tells npm which files to run for npm start? How does npm knows which files to run?
In your package.json file there will be a "script" named "start". The one you are running from is found here: https://github.com/angular/quickstart/blob/master/package.json
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
It is executing the command tsc && concurrently "tsc -w" "lite-server"
For usage of the tsc and concurrently node packages check out npmjs.com:
https://www.npmjs.com/package/tsc
https://www.npmjs.com/package/concurrently
you can make a alert("file name") on every file to see which one run first or console.log("file name ") ;
From npm help start
This runs an arbitrary command specified in the package's "start" property of its "scripts" object. If no "start" property is specified on the "scripts" object, it will run node server.js.
So open package.json
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Just add something to it.
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "arbitrary command"
},
I have a question about npm run.
('npm run dev' is from https://github.com/vuejs/vue-hackernews/blob/gh-pages/package.json)
{
"name": "vue-hackernews",
"version": "1.0.0",
"description": "HN clone with Vue.js using HN API",
"scripts": {
"dev": "webpack-dev-server --inline --hot --no-info",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
....
},
why does 'npm run dev' go well,
but does other commands like 'npm run webpack-dev-server'
or just 'webpack-dev-server' throw errors?
what does 'npm run' do? not just executing the value of the property of "scripts"?
( which I was thinking 'command exactly same thing')
thank you!
just 'webpack-dev-server' throw errors?
because in order for it to work, webpack-dev-server has to be added to the PATH environment variable. If you use npm run script-name, then:
In addition to the shell's pre-existing PATH, npm run adds
node_modules/.bin to the PATH provided to scripts.
check node_modules/.bin folder, you'll see webpack-dev-server there, and this executable runs the js package like this:
node "$basedir/../webpack-dev-server/bin/webpack-dev-server.js" "$#"
Another alternative is this if you're on Unix based env:
$(npm bin)/webpack-dev-server'