尝试在Node.js上运行项目时出错

时间:2020-09-16 10:22:47

标签: node.js npm webpack

我只是一个初学者,在启动该项目的前端时遇到了一个问题。

当我运行以下命令时:

npm run dev

我收到以下错误:

> cross-env NODE_ENV=development webpack-dev-server --mode=development --progress --port 8081 --open

module.js:550
   throw err;
   ^

Error: Cannot find module 'vue-loader/lib/plugin'
... 

完整错误显示在this screenshot

package.json

{
  "name": "absolutum",
  "description": "My webpack project",
  "version": "1.0.0",
  "author": "Roman Tayursky <tayursky@gmail.com>",
  "license": "MIT",
  "private": true,
  "scripts": {
    "dev": "cross-env NODE_ENV=development webpack-dev-server --mode=development --progress --port 8081 --open",
    "build": "webpack --mode=production -p --progress",
    "start": "webpack-dev-server"
  },
  "dependencies": {
    "@babel/polyfill": "~7.2",
    "fs": "0.0.1-security",
    "mango-dct": "^1.1.1",
    "mini-css-extract-plugin": "^0.7.0",
    "optimize-css-assets-webpack-plugin": "^5.0.3",
    "postcss-loader": "^3.0.0",
    "prettier": "^1.18.2",
    "style-loader": "^0.23.1",
    "stylus": "^0.54.5",
    "stylus-loader": "^3.0.2",
    "vue-drag-drop": "^1.1.4",
    "vue-input-mask": "0.0.11",
    "vue-masked-input": "^0.5.2",
    "vue-moment": "^4.0.0",
    "vuex": "^3.1.1",
    "webpack-merge": "^4.2.1",
    "webpack-sources": "^1.3.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ],
  "devDependencies": {
    "@babel/core": "~7.2",
    "@babel/plugin-proposal-class-properties": "~7.3",
    "@babel/plugin-proposal-decorators": "~7.3",
    "@babel/plugin-proposal-json-strings": "~7.2",
    "@babel/plugin-syntax-dynamic-import": "~7.2",
    "@babel/plugin-syntax-import-meta": "~7.2",
    "@babel/preset-env": "~7.3",
    "babel-loader": "^8.0",
    "compression-webpack-plugin": "^2.0.0",
    "cross-env": "^5.0.5",
    "css-loader": "^1.0.1",
    "element-ui": "^2.10.0",
    "friendly-errors-webpack-plugin": "~1.7",
    "html-webpack-plugin": "^3.2.0",
    "node-sass": "^4.5.3",
    "sass-loader": "^7.1.0",
    "uglifyjs-webpack-plugin": "^1.3.0",
    "vue": "^2.6.10",
    "vue-axios": "^2.1.4",
    "vue-cli": "^2.9.6",
    "vue-loader": "^14.2.2",
    "vue-router": "^3.0.6",
    "vue-style-loader": "^4.1.2",
    "vue-template-compiler": "^2.6",
    "webpack": "^4.35.2",
    "webpack-bundle-analyzer": "^3.3.2",
    "webpack-cli": "^3.3.5",
    "webpack-dev-server": "^3.7.2",
    "webpack-serve": "^3.1.0"
  }
}

请帮助我。

2 个答案:

答案 0 :(得分:0)

似乎您刚刚下载了该项目并尝试运行,

在运行之前,您需要安装项目的package.json中列出的依赖项

安装使用(确保您位于根路径中,即package.json所在的位置)

npm install

然后运行

答案 1 :(得分:0)

如果有人有用,那么我在package.json中已删除/注释了vue-loader,并通过npm i vue-loader手动安装了它。就我而言,我还需要安装axios。非常感谢:)