我每次在命令提示符下都得到以下错误基本上我无法打开我的服务器,因为package.json中的启动抛出错误,我无法找到什么问题,请建议什么是正确的方法
Microsoft Windows [Version 6.1.7600] 版权所有(c)2009 Microsoft Corporation。保留所有权利。
C:\用户\使用者> d:
D:> cd reactApp
D:\reactApp>npm install -g npm@latest
C:\Users\user\AppData\Roaming\npm\npm -> C:\Users\user\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
C:\Users\user\AppData\Roaming\npm\npx -> C:\Users\user\AppData\Roaming\npm\node_modules\npm\bin\npx-cli.js
+ npm@5.8.0
added 523 packages in 116.024s
D:\reactApp>rm -rf node_modules
'rm' is not recognized as an internal or external command,
operable program or batch file.
D:\reactApp>npm -rf node_modules
Usage: npm <command>
where <command> is one of:
access, adduser, bin, bugs, c, cache, ci, completion,
config, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, get, help, help-search, i, init, install,
install-test, it, link, list, ln, login, logout, ls,
outdated, owner, pack, ping, prefix, profile, prune,
publish, rb, rebuild, repo, restart, root, run, run-script,
s, se, search, set, shrinkwrap, star, stars, start, stop, t,
team, test, token, tst, un, uninstall, unpublish, unstar,
up, update, v, version, view, whoami
npm -h快速帮助 npm -l显示完整的使用信息 npm帮助搜索帮助 npm help npm涉及概述
Specify configs in the ini-formatted file:
C:\Users\user\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
npm@5.8.0 C:\Users\user\AppData\Roaming\npm\node_modules\npm
D:\reactApp>npm install
npm WARN babel-loader@7.1.4需要babel-core @ 6的同伴,但没有安装。您必须自己安装对等依赖项。 npm WARN reactapp@1.0.0没有存储库字段。 npm WARN可选SKIPPING OPTIONAL DEPENDENCY:fsevents@1.1.3(node_modules \ fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY:不支持的fsevents@1.1.3平台:想要{“os”:“darwin”,“arch”:“any”}(当前:{“os”:“win32”,“arch”: “64”})
removed 10 packages in 21.906s
D:\reactApp>npm start
> reactapp@1.0.0 start D:\reactApp
> npm run build
> reactapp@1.0.0 build D:\reactApp
> webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot
The CLI moved into a separate package: webpack-cli.
Please install 'webpack-cli' in addition to webpack itself to use the CLI.
-> When using npm: npm install webpack-cli -D
-> When using yarn: yarn add webpack-cli -D
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactapp@1.0.0 build: `webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactapp@1.0.0 build 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\user\AppData\Roaming\npm-cache\_logs\2018-03-27T03_57_54_881Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactapp@1.0.0 start: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactapp@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\user\AppData\Roaming\npm-cache\_logs\2018-03-27T03_57_54_983Z-debug.log
D:\reactApp>npm install -g react-scripts
C:\Users\user\AppData\Roaming\npm\react-scripts -> C:\Users\user\AppData\Roaming\npm\node_modules\react-scripts\bin\react-scripts.js
> uglifyjs-webpack-plugin@0.4.6 postinstall C:\Users\user\AppData\Roaming\npm\node_modules\react-scripts\node_modules\uglifyjs-webpack-plugin
> node lib/post_install.js
npm WARN ajv-keywords@3.1.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\react-scripts\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ react-scripts@1.1.1
added 1324 packages from 785 contributors in 453.077s
D:\reactApp>npm start
> reactapp@1.0.0 start D:\reactApp
> npm run build
> reactapp@1.0.0 build D:\reactApp
> webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot
The CLI moved into a separate package: webpack-cli.
Please install 'webpack-cli' in addition to webpack itself to use the CLI.
-> When using npm: npm install webpack-cli -D
-> When using yarn: yarn add webpack-cli -D
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactapp@1.0.0 build: `webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactapp@1.0.0 build 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\user\AppData\Roaming\npm-cache\_logs\2018-03-27T04_06_58_572Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactapp@1.0.0 start: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactapp@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\user\AppData\Roaming\npm-cache\_logs\2018-03-27T04_06_58_697Z-debug.log
D:\reactApp>npm start
my package.json file is
{
"name": "reactapp",
"version": "1.0.0",
"description": "some basics reactjs",
"main": "index.js",
"scripts": {
"start": "npm run build",
"build": "webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot",
"build:prod": "webpack -p && cp src/index.html dist/index.html"
},
"keywords": [
"reactjs"
],
"author": "Harsh mewari",
"license": "ISC",
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0"
},
"devDependencies": {
"babel-loader": "^7.1.4",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"webpack": "^4.2.0",
"webpack-dev-server": "^3.1.1"
}
}
my webpack.config.js file is
var path=require("path");
var DIST_DIR = path.resolve(dirname,"dist");
var SRC_DIR= path.resolve(_dirname,"src");
var config={
entry: SRC_DIR + "/app/index.js",
output:{
path: DIST_DIR + "/app",
filename:"bundle.js",
publicPath:"/app"
},
modules:{
loaders:[
{
test:/\.js?/,
include: SRC_DIR,
loader:"babel-loader",
query:{
presets:["react","es2015","stage-2"]
}
}
]
};
module.exports= config;
}