leotian / my-node-blog Goto Github PK
View Code? Open in Web Editor NEWNodeJs版blog的远程仓库
NodeJs版blog的远程仓库
设置端口号可以放在:bin/www内或app.js,但是好像会有冲突,如果要用supervisor则必须在app.js中配置,supervisor是帮助实时编译的程序。
在密码错误时和用户不存在的情况下用return res.redirect('/login');?
不加return的话res.redirect直接跳转就报错。
Error: Can't set headers after they are sent.
登录成功的res.redirect 就不用加return?
express-session deprecated undefined resave option; provide resave option app.js:39:9
express-session deprecated undefined saveUninitialized option; provide saveUninitialized option app.js:39:9
resave: false,//重新保存:强制会话保存即使是未修改的。(默认值ture)
saveUninitialized: true,//强制保存未初始化的会话到存储器
“npm ERR! extraneous means a package is installed but is not listed in your project's package.json.”
错误的原因是项目的package.json中没有添加模块信息,则会报extraneous错误的模块信息。
package.json:存储着工程的信息及模块依赖,当在 dependencies 中添加依赖的模块时,运行 npm install,npm 会检查当前目录下的 package.json,并自动安装所有指定的模块,安装目录是当前工程的
node_modules。
app.use(flash()); 这句放在app.use(session(…));后面。
flash 是一个在 session 中用于存储信息的特定区域。信息写入 flash ,下一次显示完毕后即被清除。典型的应用是结合重定向的功能,确保信息是提供给下一个被渲染的页面。所以要现有session才有flash。
Error: Cannot find module '../build/Release/bson'的解决办法
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
这两行说的是没有发现bson模块。npm查看是否有bson,没有则安装:
npm install bson
然后将My-Node-blog\node_modules\mongodb\node_modules\bson\ext\index.js中的bson = require('../build/Release/bson')改成bson = require('bson') ,重新运行。如果npm ls后发现已经安装好,则直接修改require的路径。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.