54sword / xiaoduyu.com

🐟小度鱼 - 年轻人的交流社区 https://www.xiaoduyu.com
597 stars 148 forks source link

npm run dev 项目启动报错 #3

Closed jingchenxu closed 7 years ago

jingchenxu commented 7 years ago

`PS D:\githubProject\xiaoduyu.com> npm run dev

xiaoduyu@0.1.0 dev D:\githubProject\xiaoduyu.com NODE_ENV=development NODE=false webpack --progress --colors --config webpack.development.config.js && NODE_ENV=development NODE=true node server

'NODE_ENV' 不是内部或外部命令,也不是可运行的程序 或批处理文件。

npm ERR! Windows_NT 10.0.14393 npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "dev" npm ERR! node v7.4.0 npm ERR! npm v4.0.5 npm ERR! code ELIFECYCLE npm ERR! xiaoduyu@0.1.0 dev: NODE_ENV=development __NODE__=false webpack --progress --colors --config webpack.development.config.js && NODE_ENV=development __NODE__=true node server npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the xiaoduyu@0.1.0 dev script 'NODE_ENV=development NODE=false webpack --progress --colors --config webpack.development.config.js && NODE_ENV=development NODE=true node s erver'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the xiaoduyu package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! NODE_ENV=development NODE=false webpack --progress --colors --config webpack.development.config.js && NODE_ENV=development NODE=true node server npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs xiaoduyu npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls xiaoduyu npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! D:\githubProject\xiaoduyu.com\npm-debug.log`

54sword commented 7 years ago

你好,我还没有在 Windows 上部署过,因此可能会有一些异常。 你可以尝试在环境变量参数前面加上 set 方式,在 Windows 上设置环境变量。 http://stackoverflow.com/questions/9249830/how-can-i-set-node-env-production-in-windows

将 package.json 第六行代码的启动脚本修改成如下试一试(没有windows电脑,未测试) set NODE_ENV=development set NODE=false webpack --progress --colors --config webpack.development.config.js && set NODE_ENV=development set NODE=true node server

fengfeng94 commented 7 years ago

@54sword 我加了cross-env 在package.json 第六行代码以后,让NODE_ENV=development能够以unix方式设置环境变量,然后在windows上也能兼容运行。但是又报了如下错,你知道是什么问题吗 xiaoduyu@0.2.0 dev D:\BaiduYunDownload\React\xiaoduyu.com-master

cross-env NODE_ENV=development NODE=false webpack --progress --colors --config webpack.development.config.js && cross-env NODE_ENV=development NODE=true node server

module.js:471 throw err; ^

Error: Cannot find module './config' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object. (D:\BaiduYunDownload\React\xiaoduyu.com-master\webpack.development.config.js:9:14) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at module.exports (D:\BaiduYunDownload\React\xiaoduyu.com-master\node_modules._webpack@1.15.0@webpack\bin\convert-argv.js:80:13) at Object. (D:\BaiduYunDownload\React\xiaoduyu.com-master\node_modules._webpack@1.15.0@webpack\bin\webpack.js:39:40) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10)

npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "dev" npm ERR! node v6.10.1 npm ERR! npm v3.10.10 npm ERR! code ELIFECYCLE npm ERR! xiaoduyu@0.2.0 dev: cross-env NODE_ENV=development __NODE__=false webpack --progress --colors --config webpack.development.config.js && cross-env NODE_ENV=development __NODE__=true node server npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the xiaoduyu@0.2.0 dev script ' cross-env NODE_ENV=development NODE=false webpack --progress --colors --config webpack.development.config.js && cross-env NODE_ENV=development NODE=true node server'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the xiaoduyu package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! cross-env NODE_ENV=development NODE=false webpack --progress --colors --config webpack.development.config.js && cross-env NODE_ENV=development NODE=true node server npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs xiaoduyu npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls xiaoduyu npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! D:\BaiduYunDownload\React\xiaoduyu.com-master\npm-debug.log

54sword commented 7 years ago

@fengfeng94 应该是没有配置文件 cp config/index.default.js config/index.js 执行如上代码后,再试一试

54sword commented 7 years ago

@fengfeng94 刚刚10分钟前,有更新了代码,建议重新clone一份哈 服务端API有新的改动,与老代码有点不兼容

fengfeng94 commented 7 years ago

@54sword 可以了感谢,顺便问下。你学node是怎么学的,看什么书吗?

54sword commented 7 years ago

@fengfeng94

书: https://www.amazon.cn/图书/dp/B00GOM5IL4/ref=sr_1_1?ie=UTF8&qid=1493645249&sr=8-1&keywords=深入浅出node.js

视频: http://www.imooc.com/learn/75

然后就是使用起来,做实战练习做出一些东西