【error】npm安装express报错: command not found

本文讨论了在使用Node.js开发时遇到的三个常见问题:Express命令未找到、tejsmicroblog创建错误模板引擎以及app.js无反应。文章详细解释了每个问题的初始操作步骤、遇到的情况和解决方案,旨在帮助开发者避免常见的开发陷阱。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自:http://blog.youkuaiyun.com/dai_jing/article/details/38087443


Express Command not found
最初操作:跟着《nodejs开发指南》敲npm install -g express,安装好了,就在linux命令行敲express --help就出现上面的原因了。
解决方法:在安装一个包npm install -g express-generator
原因:express3+已经把创建一个APP的功能分离出来为express-generator,没它你创建不了应用程序
2 express -t ejs microblog创建的不是ejs模板引擎而是jade模板引擎
最初操作:跟着《nodejs开发指南》在命令行敲express -t ejs microblog是用来创建应用程序的,应用程序的名字叫microblog、模板引擎是ejs
出现情况:但是通过查看microblog文件夹中的package.json中知道创建出来的不是ejs模板而是jade模板引擎
解决方法:版本不一样,用错命令了,应该是express -e microblog(-e就是ejs模板)
3 node app.js没效果
最初操作:跟着《nodejs开发指南》在命令行敲node app.js,然后就用浏览器访问监听的3000端口
出现情况:访问不到页面
解决方法:版本不一样,用错命令了,应该是npm start

C:\own\app\Node\node_cache C:\Users\qusg>npm config set cache "%APPDATA%\npm-cache" C:\Users\qusg>npm install express -g npm error code EPERM npm error syscall mkdir npm error path C:\own\app\Node\node_global\node_modules npm error errno -4048 npm error Error: EPERM: operation not permitted, mkdir 'C:\own\app\Node\node_global\node_modules' npm error at async mkdir (node:internal/fs/promises:858:10) npm error at async C:\own\app\Node\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:624:20 npm error at async Promise.allSettled (index 0) npm error at async [reifyPackages] (C:\own\app\Node\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:325:11) npm error at async Arborist.reify (C:\own\app\Node\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:142:5) npm error at async Install.exec (C:\own\app\Node\node_modules\npm\lib\commands\install.js:150:5) npm error at async Npm.exec (C:\own\app\Node\node_modules\npm\lib\npm.js:207:9) npm error at async module.exports (C:\own\app\Node\node_modules\npm\lib\cli\entry.js:74:5) { npm error errno: -4048, npm error code: 'EPERM', npm error syscall: 'mkdir', npm error path: 'C:\\own\\app\\Node\\node_global\\node_modules' npm error } npm error npm error The operation was rejected by your operating system. npm error It's possible that the file was already in use (by a text editor or antivirus), npm error or that you lack permissions to access it. npm error npm error If you believe this might be a permissions issue, please double-check the npm error permissions of the file and its containing directories, or try running npm error the command again as root/Administrator. npm notice npm notice New major version of npm available! 10.9.3 -> 11.5.2 npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.5.2 npm notice To update run: npm install -g npm@11.5.2 npm notice npm error A complete log of this run can be found in: C:\Users\qusg\AppData\Roaming\npm-cache\_logs\2025-08-07T01_59_22_309Z-debug-0.log
最新发布
08-08
C:\Users\赵倩>npm install express -g npm error code EPERM npm error syscall mkdir npm error path E:\Nodejs\node_cache\node_modules npm error errno -4048 npm error Error: EPERM: operation not permitted, mkdir 'E:\Nodejs\node_cache\node_modules' npm error at async mkdir (node:internal/fs/promises:858:10) npm error at async E:\Nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:624:20 npm error at async Promise.allSettled (index 0) npm error at async [reifyPackages] (E:\Nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:325:11) npm error at async Arborist.reify (E:\Nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:142:5) npm error at async Install.exec (E:\Nodejs\node_modules\npm\lib\commands\install.js:150:5) npm error at async Npm.exec (E:\Nodejs\node_modules\npm\lib\npm.js:207:9) npm error at async module.exports (E:\Nodejs\node_modules\npm\lib\cli\entry.js:74:5) { npm error errno: -4048, npm error code: 'EPERM', npm error syscall: 'mkdir', npm error path: 'E:\\Nodejs\\node_cache\\node_modules' npm error } npm error npm error The operation was rejected by your operating system. npm error It's possible that the file was already in use (by a text editor or antivirus), npm error or that you lack permissions to access it. npm error npm error If you believe this might be a permissions issue, please double-check the npm error permissions of the file and its containing directories, or try running npm error the command again as root/Administrator. npm error A complete log of this run can be found in: D:\Nodejs\node_cache\_logs\2025-07-09T23_54_29_330Z-debug-0.log npm error code EPERM npm error syscall mkdir
07-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值