在腾讯云win10 windows Server2016下用cmd管理员模式运行“'sudo npm install -g npm”安装npm时报错,如下图:
完整日志:
日志如下:
timing action:finalize Completed in 1002ms
3270 verbose unlock done using C:\Users\Administrator\AppData\Roaming\npm-cache\_locks\staging-abc99ad82fab7dbe.lock for C:\Users\Administrator\AppData\Roaming\npm\node_modules\.staging
3271 timing stage:rollbackFailedOptional Completed in 9ms
3272 timing stage:runTopLevelLifecycles Completed in 12832ms
3273 verbose stack Error: EPERM: operation not permitted, rename 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@tootallnate' -> 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules\@tootallnate'
3274 verbose cwd C:\GreaterWMS\templates
3275 verbose Windows_NT 10.0.14393
3276 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "npm"
3277 verbose node v14.16.1
3278 verbose npm v6.14.12
3279 error code EPERM
3280 error syscall rename
3281 error path C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@tootallnate
3282 error dest C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules\@tootallnate
3283 error errno -4048
3284 error Error: EPERM: operation not permitted, rename 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@tootallnate' -> 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules\@tootallnate'
3284 error [OperationalError: EPERM: operation not permitted, rename 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@tootallnate' -> 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules\@tootallnate'] {
3284 error cause: [Error: EPERM: operation not permitted, rename 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@tootallnate' -> 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules\@tootallnate'] {
3284 error errno: -4048,
3284 error code: 'EPERM',
3284 error syscall: 'rename',
3284 error path: 'C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\.node-gyp.DELETE\\node_modules\\@tootallnate',
3284 error dest: 'C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\node_modules\\@tootallnate'
3284 error },
3284 error errno: -4048,
3284 error code: 'EPERM',
3284 error syscall: 'rename',
3284 error path: 'C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\.node-gyp.DELETE\\node_modules\\@tootallnate',
3284 error dest: 'C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\node_modules\\@tootallnate',
3284 error parent: 'npm'
3284 error }
3285 error The operation was rejected by your operating system.
3285 error It's possible that the file was already in use (by a text editor or antivirus),
3285 error or that you lack permissions to access it.
3285 error
3285 error If you believe this might be a permissions issue, please double-check the
3285 error permissions of the file and its containing directories, or try running
3285 error the command again as root/Administrator.
3286 verbose exit [ -4048, true ]
查了一下,原来是获取用户信息的接口更新了。
大家可以这么改:
在 pages/index/index.wxml 的清空任务状态上面补充一句
<button open-type="getUserInfo">授权用户信息</button>
然后运行之前点一下授权,就可以正常使用了。
请重启小程序会话,看你命令你应该是配置后没有重启服务
pm2 restart app
我发现你在SSH上直接输入.login,这个登陆地址是在小程序上实现的,并不是在SSH上使用!
app.js 里面的代码应为:
// 引用 express 来支持 HTTP Server 的实现
const express = require('express');
// 引用 wafer-session 支持小程序会话
const waferSession = require('wafer-node-session');
// 使用 MongoDB 作为会话的存储
const MongoStore = require('connect-mongo')(waferSession);
// 引入配置文件
const config = require('./config');
// 创建一个 express 实例
const app = express();
// 添加会话中间件,登录地址是 /login
app.use(waferSession({
appId: config.appId,
appSecret: config.appSecret,
loginPath: '/login',
store: new MongoStore({
url: `mongodb://${config.mongoUser}:${config.mongoPass}@${config.mongoHost}:${config.mongoPort}/${config.mongoDb}`
})
}));
// 在路由 /me 下,输出会话里包含的用户信息
app.use('/me', (request, response, next) => {
response.json(request.session ? request.session.userInfo : { noBody: true });
if (request.session) {
console.log(`Wafer session success with openId=${request.session.userInfo.openId}`);
}
});
// 实现一个中间件,对于未处理的请求,都输出 "Response from express"
app.use((request, response, next) => {
response.write('Response from express');
response.end();
});
// 监听端口,等待连接
app.listen(config.serverPort);
// 输出服务器启动日志
console.log(`Server listening at http://127.0.0.1:${config.serverPort}`);
修改后输入:pm2 restart app
即可