前端新手,最近在自学中用express+mongoose写了个博客,求轻喷○| ̄|-_
发布于 3 年前 作者 chickencyj 4874 次浏览 来自 分享

第一次写了一个完整的小项目(js和node),可能里面还有很多要调试的地方,也没有作网站安全方面的考虑,后期会全部加上。 动态效果演示 动态效果如果图片太大看不见可以看这个动态效果演示或者去github的Readme上也有 详细文档说明进Github传送门

22 回复

mark 自豪地采用 CNodeJS ionic

mark

虽然看不懂太多

就说一点,关于webpack 下的entry 感觉实在太冗余 可以使用blob 模块进行自动获取 详见 陈学家写的lean react 中关于webpack的介绍

其次,windows 下bcrypt 模块那个大坑真是太痛苦了 … 无法安装模块

最近在找 multer 的 demo,学习了。 不过楼主缩进的规则是什么? github 里面看缩进太夸张了

@NumerHero 我也第一次用webpack,谢谢提意见,学习了。不过你说的window下bcrypt 模块那个大坑我的确不太清楚吖囧,我查了下,是这个情况吗?https://cnodejs.org/topic/53040bc95366a72a2c2128b9

@IchiNiNiIchi 我采用的是tab键两个空格的缩进

@IchiNiNiIchi 好吧,我看出来了,有些文件是四个空格。。。我也醉了,因为分别在两台电脑上写的= =,我再回去把这些修改一下

ubuntu系统报错 /home/user/Documents/node/blog-by-nodejs-master/node_modules/.npminstall/bindings/1.2.1/bindings/bindings.js:83 throw e 请问什么原因?

@MyNodeJs 是npm start的时候报错吗?mongodb开启了吗?

@MyNodeJs 你的node.js 升了版本吧?试试npm install bcrypt

@chickencyj 是npm start时报的错,node也升级到v6了,mongodb开启了,我安装下bcrypt试试

@MyNodeJs 安装了,还是报错,错误是

blog@1.0.0 start /home/user/Documents/node/blog-by-nodejs-master node app.js

/home/user/Documents/node/blog-by-nodejs-master/node_modules/.npminstall/bindings/1.2.1/bindings/bindings.js:83 throw e ^

Error: Module version mismatch. Expected 48, got 46. at Error (native) at Object.Module._extensions…node (module.js:568:18) at Module.load (module.js:458:32) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3) at Module.require (module.js:468:17) at require (internal/module.js:20:19) at bindings (/home/user/Documents/node/blog-by-nodejs-master/node_modules/.npminstall/bindings/1.2.1/bindings/bindings.js:76:44) at Object.<anonymous> (/home/user/Documents/node/blog-by-nodejs-master/node_modules/.npminstall/bcrypt/0.8.7/bcrypt/bcrypt.js:3:35) at Module._compile (module.js:541:32) at Object.Module._extensions…js (module.js:550:10) at Module.load (module.js:458:32) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3) at Module.require (module.js:468:17) at require (internal/module.js:20:19) at Object.<anonymous> (/home/user/Documents/node/blog-by-nodejs-master/app/schema/user.js:6:16) at Module._compile (module.js:541:32) at Object.Module._extensions…js (module.js:550:10) at Module.load (module.js:458:32) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3)

npm ERR! Linux 4.4.0-31-generic npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” "start" npm ERR! node v6.3.1 npm ERR! npm v3.10.3 npm ERR! code ELIFECYCLE npm ERR! blog@1.0.0 start: node app.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the blog@1.0.0 start script ‘node app.js’. 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 blog package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node app.js npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs blog npm ERR! Or if that isn’t available, you can get their info via: npm ERR! npm owner ls blog npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! /home/user/Documents/node/blog-by-nodejs-master/npm-debug.log 不知道什么原因 执行npm start时报的错

@MyNodeJs 删除node_modules文件夹然后重新 npm install试试

@chickencyj 好,先也删除安装试了,不行,我再试试

@MyNodeJs 删除了node_moduls后,先npm install bcrypt又执行cnpm install后报了这个错误 module.js:442 throw err; ^

Error: Cannot find module '…/…/models/User’ at Function.Module._resolveFilename (module.js:440:15) at Function.Module._load (module.js:388:25) at Module.require (module.js:468:17) at require (internal/module.js:20:19) at Object.<anonymous> (/home/user/Documents/node/blog-by-nodejs-master/app/controller/manager/main.js:3:14) at Module._compile (module.js:541:32) at Object.Module._extensions…js (module.js:550:10) at Module.load (module.js:458:32) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3) at Module.require (module.js:468:17) at require (internal/module.js:20:19) at manager (/home/user/Documents/node/blog-by-nodejs-master/configs/manager.js:29:9) at Object.<anonymous> (/home/user/Documents/node/blog-by-nodejs-master/app.js:55:45) at Module._compile (module.js:541:32) at Object.Module._extensions…js (module.js:550:10) at Module.load (module.js:458:32) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3) at Module.runMain (module.js:575:10) at run (bootstrap_node.js:352:7) at startup (bootstrap_node.js:144:9)

npm ERR! Linux 4.4.0-31-generic npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” "start" npm ERR! node v6.3.1 npm ERR! npm v3.10.3 npm ERR! code ELIFECYCLE npm ERR! blog@1.0.0 start: node app.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the blog@1.0.0 start script ‘node app.js’. 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 blog package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node app.js npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs blog npm ERR! Or if that isn’t available, you can get their info via: npm ERR! npm owner ls blog npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! /home/user/Documents/node/blog-by-nodejs-master/npm-debug.log 什么原因呀?

@chickencyj 连接mongodb,在浏览器访问http://localhost:27017/显示It looks like you are trying to access MongoDB over HTTP on the native driver port. 这样算是连接上数据库了吧?

@MyNodeJs 连接数据库显示的 2016-08-09T09:36:37.930+0800 W CONTROL [main] 32-bit servers don’t have journaling enabled by default. Please use --journal if you want durability. 2016-08-09T09:36:37.930+0800 I CONTROL [main] 2016-08-09T09:36:37.936+0800 I CONTROL [initandlisten] MongoDB starting : pid=2408 port=27017 dbpath=/data/db 32-bit host=user-virtual-machine 2016-08-09T09:36:37.936+0800 I CONTROL [initandlisten] db version v3.2.8 2016-08-09T09:36:37.936+0800 I CONTROL [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0 2016-08-09T09:36:37.936+0800 I CONTROL [initandlisten] allocator: tcmalloc 2016-08-09T09:36:37.937+0800 I CONTROL [initandlisten] modules: none 2016-08-09T09:36:37.937+0800 I CONTROL [initandlisten] build environment: 2016-08-09T09:36:37.937+0800 I CONTROL [initandlisten] distarch: i686 2016-08-09T09:36:37.937+0800 I CONTROL [initandlisten] target_arch: i386 2016-08-09T09:36:37.937+0800 I CONTROL [initandlisten] options: { storage: { engine: “mmapv1” } } 2016-08-09T09:36:38.066+0800 I CONTROL [initandlisten] 2016-08-09T09:36:38.066+0800 I CONTROL [initandlisten] ** WARNING: This 32-bit MongoDB binary is deprecated 2016-08-09T09:36:38.066+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2016-08-09T09:36:38.066+0800 I CONTROL [initandlisten] 2016-08-09T09:36:38.066+0800 I CONTROL [initandlisten] 2016-08-09T09:36:38.067+0800 I CONTROL [initandlisten] ** NOTE: This is a 32 bit MongoDB binary. 2016-08-09T09:36:38.067+0800 I CONTROL [initandlisten] ** 32 bit builds are limited to less than 2GB of data (or less with --journal). 2016-08-09T09:36:38.067+0800 I CONTROL [initandlisten] ** Note that journaling defaults to off for 32 bit and is currently off. 2016-08-09T09:36:38.067+0800 I CONTROL [initandlisten] ** See http://dochub.mongodb.org/core/32bit 2016-08-09T09:36:38.067+0800 I CONTROL [initandlisten] 2016-08-09T09:36:38.067+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’. 2016-08-09T09:36:38.067+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never’ 2016-08-09T09:36:38.067+0800 I CONTROL [initandlisten] 2016-08-09T09:36:38.068+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’. 2016-08-09T09:36:38.068+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never’ 2016-08-09T09:36:38.068+0800 I CONTROL [initandlisten] 2016-08-09T09:36:38.722+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data’ 2016-08-09T09:36:38.723+0800 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker 2016-08-09T09:36:38.730+0800 I NETWORK [initandlisten] waiting for connections on port 27017 2016-08-09T09:36:39.061+0800 I FTDC [ftdc] Unclean full-time diagnostic data capture shutdown detected, found interim file, some metrics may have been lost. OK 2016-08-09T09:51:39.224+0800 I COMMAND [PeriodicTaskRunner] task: DBConnectionPool-cleaner took: 193ms 2016-08-09T10:16:54.462+0800 I NETWORK [initandlisten] connection accepted from 127.0.0.1:59612 #1 (1 connection now open) 2016-08-09T10:16:54.585+0800 I NETWORK [conn1] end connection 127.0.0.1:59612 (0 connections now open) 2016-08-09T10:16:55.092+0800 I NETWORK [initandlisten] connection accepted from 127.0.0.1:59616 #2 (1 connection now open) 2016-08-09T10:16:55.155+0800 I NETWORK [conn2] end connection 127.0.0.1:59616 (0 connections now open) 2016-08-09T10:24:02.516+0800 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60078 #3 (1 connection now open) 2016-08-09T10:24:02.527+0800 I NETWORK [conn3] end connection 127.0.0.1:60078 (0 connections now open) 2016-08-09T10:24:45.843+0800 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60098 #4 (1 connection now open) 2016-08-09T10:24:45.866+0800 I NETWORK [conn4] end connection 127.0.0.1:60098 (0 connections now open) 请问有错吗?

@NumerHero bcrypt 可以换成 bcryptjs 这个模块 他们的所有方法都是一样的,并且在win下没那么多的坑

回到顶部