problem description
how do I run npm run dev shell scripts in Nodejs?
the environmental background of the problems and what methods you have tried
1., npm run script a node script file in the module built by webpack, but I think running other npm run, in this script file tried require ("child_process") .exec but failed, and there was no response so far.
related codes
var exec = require ("child_process") .execSync
exec (" npm run dev")
what result do you expect? What is the error message actually seen?
or how to correctly execute script in package.json in the node script js file?
add package.json content
{
"name": "vue",
"version": "1.0.0",
"description": "A Vue.js project",
"author": "author@gmail.com",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"modify": "node script/modify-path.js",
"build:prod": "npm run modify && npm run build --no-cache",
"start": "npm run dev",
"lint": "eslint --ext .js,.vue src",
"build": "node build/build.js"
},
"dependencies": {
"fg-loadcss": "^2.0.1",
"vue-router": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-eslint": "^8.2.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"chalk": "^2.0.1",
"commander": "^2.16.0",
"copy-webpack-plugin": "^4.0.1",
"cross-env": "^5.2.0",
"css-loader": "^0.28.0",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"eslint-plugin-vue": "^4.7.0",
"execa": "^0.10.0",
"file-loader": "^1.1.11",
"fontfaceobserver": "^2.0.13",
"fontmin": "^0.9.7-beta",
"fontmin-webpack": "^2.0.1",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^3.2.0",
"inquirer": "^6.0.0",
"js-yaml": "^3.12.0",
"mini-css-extract-plugin": "^0.4.1",
"node-notifier": "^5.1.2",
"node-sass": "^4.9.2",
"optimize-css-assets-webpack-plugin": "^5.0.0",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-url": "^7.2.1",
"rimraf": "^2.6.0",
"sass-loader": "^7.0.3",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^1.0.1",
"vue": "^2.5.16",
"vue-loader": "^15.2.4",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webfont-webpack-plugin": "^0.2.2",
"webpack": "^4.16.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4",
"webpack-merge": "^4.1.0"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}