当我想运行我的vue-cli项目时出现这个奇怪的错误:
ERROR Error: Cannot find module 'websocket-driver'
Error: Cannot find module 'websocket-driver'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/me/Cloud/workspace/atom/WebApps/myproject/node_modules/faye-websocket/lib/faye/websocket.js:8:14)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myproject@1.0.0 start: `vue-cli-service serve --copy`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myproject@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/me/.npm/_logs/2018-10-17T07_38_22_837Z-debug.log
我尝试了以下方法来安装websocket-driver模块,但没有一种尝试对我有用:
npm i websocket-driver
,
npm i -g
and n
的websocket驱动程序websocket-driver -D
npm list faye-websocket
表明此软件包是@vue/cli-service
的一部分,所以我很惊讶地看到没有其他人报告此问题。
下面是我的npm软件包文件:
package.json
{
"name": "myproject",
"description": "",
"version": "1.0.0",
"private": false,
"main": "main.js",
"license": "GPL-3.0",
"repository": {
"type": "git",
"url": ""
},
"scripts": {
"serve": "vue-cli-service serve",
"start": "vue-cli-service serve --copy",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"vue": "~2.5.0",
"vue-router": "~3.0.0",
"websocket-driver": "0.7.0"
},
"devDependencies": {
"@babel/core": "~7.0.0",
"@babel/helper-module-imports": "~7.0.0",
"@maidsafe/safe-node-app": "~0.9.1",
"@vue/cli-plugin-babel": "3.0.0-alpha.3",
"@vue/cli-plugin-eslint": "~3.0.0",
"@vue/cli-service": "~3.0.0",
"@vue/eslint-config-standard": "3.0.0-beta.9",
"ajv": "~6.0.0",
"babel-plugin-root-import": "~6.1.0",
"eslint": "~4.19.0",
"eslint-plugin-node": "~6.0.0",
"eslint-plugin-promise": "~4.0.0",
"eslint-plugin-standard": "~3.0.0",
"vue-template-compiler": "~2.5.0"
}
}
答案 0 :(得分:-1)
通过删除node_modules
并重新安装软件包来解决。