2016-09-19 73 views
1

我正在嘗試設置reactjs項目並使用實時服務器。我的項目結構 -實時服務器找不到指定的文件

fa/ 
-node-modules/ 
    ... 
-public/ 
    bundle.js 
    index.html 
-src/ 
    app.js 
package.json 

我的package.json文件 -

{ 
    "name": "fa", 
    "version": "1.0.0", 
    "description": "", 
    "main": "index.js", 
    "scripts": { 
    "build": "watchify src/app.js -o public/bundle.js -t [ babelify --presets [ react es2015 ] ]", 
    "server": "cd public; live-server --port=1234 --entry-file=index.html" 
    }, 
    "keywords": [], 
    "author": "", 
    "license": "ISC", 
    "dependencies": { 
    "babel-preset-es2015": "^6.14.0", 
    "babel-preset-react": "^6.11.1", 
    "babelify": "^7.3.0", 
    "live-server": "^1.1.0", 
    "watchify": "^3.7.0" 
    } 

} 

我跑了另一個,那麼 「故宮運行服務器」 上的一個CMD 「運行故宮建」。它給出了錯誤 -

17 error Windows_NT 6.2.9200 
18 error argv "E:\\Program Files\\nodejs\\node.exe" "E:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "server" 
19 error node v6.6.0 
20 error npm v3.10.3`enter code here` 
21 error code ELIFECYCLE 
22 error [email protected] server: `cd public; live-server --port=1234 --entry-file=index.html` 
22 error Exit status 1 
23 error Failed at the [email protected] server script 'cd public; live-server --port=1234 --entry-file=index.html'. 
23 error Make sure you have the latest version of node.js and npm installed. 
23 error If you do, this is most likely a problem with the fa package, 
23 error not with npm itself. 
23 error Tell the author that this fails on your system: 
23 error  cd public; live-server --port=1234 --entry-file=index.html 
23 error You can get information on how to open an issue for this project with: 
23 error  npm bugs fa 
23 error Or if that isn't available, you can get their info via: 
23 error  npm owner ls fa 
23 error There is likely additional logging output above. 
24 verbose exit [ 1, true ] 

我做錯了什麼?

回答

2

面臨同樣的問題。更改如下:

"server": "cd public; live-server --port=1234 --entry-file=index.html" 

這樣:

"server": "live-server --port=1234 --open=public --entry-file=index.html" 

出於某種原因,它不處理cd public

更多參考:https://www.npmjs.com/package/live-server

1

我知道這個問題已經有很久以前就已經回答了。

真正的答案是改變如下:

"server": "cd public; live-server --port=1234 --entry-file=index.html" 

這個

"server": "cd public & live-server --port=1234 --entry-file=index.html" 

只要把&