简体   繁体   English

npm启动运行错误“ var before = prev.prev || {}; TypeError:无法读取未定义的属性“ prev”

[英]npm start run error “var before = prev.prev || {}; TypeError: Cannot read property 'prev' of undefined”

Currently I am trying to run a very basic to do list using node. 目前,我正在尝试使用节点运行一个非常基本的待办事项列表。 After setting up package.json and server.js, I ran npm start run, but I am getting a weird error. 设置package.json和server.js之后,我运行了npm start run,但是出现一个奇怪的错误。

UPDATE: Here is the basic code and .json file: enter image description here 更新:这是基本代码和.json文件: 在此处输入图像描述

var express = require('express'), var express = require('express'),
app = express(), app = express(),
port =process.env.PORT ||3000; 端口= process.env.PORT || 3000;

app.listen(port); app.listen(端口);

console.log('todo list RESTful API server started on: ' + port); console.log('待办事项列表RESTful API服务器启动于:'+端口);

This is the error: 这是错误: 在此处输入图片说明

This is the complete log page: 这是完整的日志页面: 在此处输入图片说明

I ran into the same problem with nodemon when running my test scripts in a node.js api. 在node.js api中运行测试脚本时,我遇到了与nodemon相同的问题。

It seems the error is related to this issue with nanomatch, a package nodemon uses, a link to the issue: https://github.com/micromatch/nanomatch/issues/15 . 看来该错误与nanomatch这个问题相关,nodemon使用了一个软件包,该链接指向该问题: https : //github.com/micromatch/nanomatch/issues/15

I solved it with the following steps: 我通过以下步骤解决了它:

  1. Verify the version of nanomatch in node_modules/nanomatch/package.json if the version is 1.2.11 (I also had a similar issue with 1.2.9) you need to change its version. 如果版本为1.2.11(我在1.2.9中也遇到类似问题),请在node_modules / nanomatch / package.json中验证nanomatch的版本,您需要更改其版本。
  2. Run npm i nanomatch@1.2.13 (--save or --save-dev according to your situation) 运行npm i nanomatch@1.2.13(--save或--save-dev根据您的情况)

After these steps nodemon worked for me. 经过这些步骤,nodemon为我工作。 Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM