通过终端创建完整的目录结构/骨架 - expressJS / nodeJS

时间:2014-02-27 18:46:19

标签: node.js web-applications express directory

我在互联网上看到了一些关于如何使用带有expressJS的命令行为节点项目创建完整目录结构的技巧。 以下是一些例子:

express express-skeleton<< http://quickleft.com/blog/getting-started-with-express-in-node

./node_modules/.bin/express -t ejs<< http://naholyr.fr/2011/08/ecrire-service-rest-nodejs-express-partie-1/

--l<< http://www.techrepublic.com/article/build-nodejs-web-applications-with-express/

但这些都不适合我。我已安装express并更新它以使用npm update express -g全局安装它,但我的终端甚至不识别命令行express。

如何使用命令行轻松构建Web应用程序框架?非常感谢

编辑:运行npm install -g express命令行时,收到以下错误消息:

npm http GET https://registry.npmjs.org/express
npm http 200 https://registry.npmjs.org/express
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/express'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/express']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/express',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/express',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 13.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "express"
npm ERR! cwd /Users/arnauddrizard/Documents/Dev/RestAPI
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path /usr/local/lib/node_modules/express
npm ERR! fstream_path /usr/local/lib/node_modules/express
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/express'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/arnauddrizard/Documents/Dev/RestAPI/npm-debug.log
npm ERR! not ok code 0

2 个答案:

答案 0 :(得分:0)

运行npm install -g express时会得到什么输出?问题很可能是npm install -g没有安装到PATH中的某个地方。

答案 1 :(得分:0)

npm无法在您的应用程序文件夹中创建文件夹。 为您的文件夹提供足够的权限,我希望能解决您的问题。