admin管理员组文章数量:1434893
I am testing the sample code of javascript
.
There is script like simple.js
under demos
directory.
I run demo by this mand yarn build-demos && http-server demos/
simple.js
is piled to simple_bundle.js
and server works.
However everytime I change simple.js
, I need to restart server.
Is there any good short cut for this purpose??
I am not familiar with npm
and webpack
Any help is appreciated.
My package.json is here below:
{
"name": "@magenta/sketch",
"version": "0.2.0",
"description": "Make sketches in the browser with machine learning.",
"main": "es5/index.js",
"types": "es5/index.d.ts",
"jsdelivr": "dist/magentasketch.js",
"unpkg": "dist/magentasketch.js",
"dependencies": {
"@tensorflow/tfjs": "^1.0.2"
},
"devDependencies": {
"@types/clone": "^0.1.30",
"@types/file-saver": "^1.3.0",
"@types/ndarray": "^1.0.6",
"@types/node": "^12.0.1",
"@types/tape": "^4.2.32",
"browserify": "^16.5.1",
"clang-format": "^1.2.3",
"clone": "^1.0.4",
"file-saver": "^1.3.8",
"file-saver-typescript": "^1.0.1",
"fs": "0.0.1-security",
"http-server": "^0.12.1",
"in-publish": "^2.0.0",
"minimist": "^1.2.5",
"path": "^0.12.7",
"tape": "^4.9.0",
"ts-loader": "^5.3.0",
"ts-node": "^5.0.1",
"tsify": "^3.0.4",
"tslint": "^5.9.1",
"typedoc": "^0.16.9",
"typedoc-plugin-sourcefile-url": "^1.0.3",
"typescript": "^3.3.3333",
"webpack": "^4.24.0",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.14"
},
"scripts": {
"prepublish": "yarn lint && yarn build && yarn bundle",
"build": "tsc",
"bundle": "webpack --config ./webpack/lib.config.ts",
"lint": "tslint -c ../tslint.json -p . -t verbose",
"test": "ts-node node_modules/tape/bin/tape src/**/*_test.ts",
"build-demos": "webpack --config ./webpack/demo.config.ts",
"run-demos": "yarn build-demos && http-server demos/",
"serve-demos": "http-server demos/",
"serve-dist": "http-server dist/",
"docs": "sh ../scripts/generate-docs.sh 'sketch'"
},
"author": "Magenta",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": ".git"
}
}
I am testing the sample code of javascript
.
There is script like simple.js
under demos
directory.
I run demo by this mand yarn build-demos && http-server demos/
simple.js
is piled to simple_bundle.js
and server works.
However everytime I change simple.js
, I need to restart server.
Is there any good short cut for this purpose??
I am not familiar with npm
and webpack
Any help is appreciated.
My package.json is here below:
{
"name": "@magenta/sketch",
"version": "0.2.0",
"description": "Make sketches in the browser with machine learning.",
"main": "es5/index.js",
"types": "es5/index.d.ts",
"jsdelivr": "dist/magentasketch.js",
"unpkg": "dist/magentasketch.js",
"dependencies": {
"@tensorflow/tfjs": "^1.0.2"
},
"devDependencies": {
"@types/clone": "^0.1.30",
"@types/file-saver": "^1.3.0",
"@types/ndarray": "^1.0.6",
"@types/node": "^12.0.1",
"@types/tape": "^4.2.32",
"browserify": "^16.5.1",
"clang-format": "^1.2.3",
"clone": "^1.0.4",
"file-saver": "^1.3.8",
"file-saver-typescript": "^1.0.1",
"fs": "0.0.1-security",
"http-server": "^0.12.1",
"in-publish": "^2.0.0",
"minimist": "^1.2.5",
"path": "^0.12.7",
"tape": "^4.9.0",
"ts-loader": "^5.3.0",
"ts-node": "^5.0.1",
"tsify": "^3.0.4",
"tslint": "^5.9.1",
"typedoc": "^0.16.9",
"typedoc-plugin-sourcefile-url": "^1.0.3",
"typescript": "^3.3.3333",
"webpack": "^4.24.0",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.14"
},
"scripts": {
"prepublish": "yarn lint && yarn build && yarn bundle",
"build": "tsc",
"bundle": "webpack --config ./webpack/lib.config.ts",
"lint": "tslint -c ../tslint.json -p . -t verbose",
"test": "ts-node node_modules/tape/bin/tape src/**/*_test.ts",
"build-demos": "webpack --config ./webpack/demo.config.ts",
"run-demos": "yarn build-demos && http-server demos/",
"serve-demos": "http-server demos/",
"serve-dist": "http-server dist/",
"docs": "sh ../scripts/generate-docs.sh 'sketch'"
},
"author": "Magenta",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github./tensorflow/magenta-js.git"
}
}
Share
Improve this question
edited Sep 20, 2021 at 13:41
RobC
25.1k21 gold badges84 silver badges86 bronze badges
asked Sep 20, 2021 at 10:37
whitebearwhitebear
12.5k29 gold badges149 silver badges301 bronze badges
2 Answers
Reset to default 4You might need to use Nodemon.
- You install nodemon by
npm i nodemon
- In package.json you add a script:
"dev": "nodemon dist/index.js"
- Execute the code in the console by adding
npm run dev
It should work as you want
You may consider using Nodemon.
本文标签: javascriptHow to autoreload the script by npm serverStack Overflow
版权声明:本文标题:javascript - How to auto-reload the script by npm server - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745628538a2667124.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论