如何解决npm错误!缺少脚本:dev

如何解决npm错误!缺少脚本:dev,npm,vue.js,Npm,Vue.js,我已经安装了node.js。 接下来,我使用命令安装了cnmp npm install -g cnpm --registry=https://registry.npm.taobao.org cnpm install 当我尝试命令cnpmrundev 有一个错误: npm ERR! path C:\Users\Harry\package.json npm ERR! code ENOENT npm ERR! errno -4058 npm ERR! syscall open npm ERR! en

我已经安装了node.js。 接下来,我使用命令安装了cnmp

npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install
当我尝试命令
cnpmrundev
有一个错误:

npm ERR! path C:\Users\Harry\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Harry\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Harry\AppData\Roaming\npm-cache\_logs\2018-08-03T02_48_22_663Z-debug.log
因此,我将package.json从
C:\Users\Harry\AppData\Roaming\npm\node\u modules\cnpm
移动到
'C:\Users\Harry\package.json'
但我还是犯了一个错误:

npm ERR! missing script: dev

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Harry\AppData\Roaming\npm-cache\_logs\2018-08-03T02_51_46_194Z-debug.log

我还尝试了解决类似问题的方法,例如在package.json中编辑脚本,但仍然不起作用。

也许您正在使用Vue CLI 3?如果是,则不存在“dev”构建脚本。VUE2样板项目的早期版本有一个“dev”脚本,但现在不再有了

相反,使用“serve”脚本,您的Vue项目将作为开发人员运行

npm run serve
请参阅package.json文件中使用Vue CLI 3配置的脚本

"scripts": {
         "serve": "vue-cli-service serve",
         "build": "vue-cli-service build",
         "lint": "vue-cli-service lint"    },

希望这能解决您的问题。

您是否正在使用Vue CLI 3?如果是,则不存在“dev”构建脚本。VUE2样板项目的早期版本有一个“dev”脚本,但现在不再有了

相反,使用“serve”脚本,您的Vue项目将作为开发人员运行

npm run serve
请参阅package.json文件中使用Vue CLI 3配置的脚本

"scripts": {
         "serve": "vue-cli-service serve",
         "build": "vue-cli-service build",
         "lint": "vue-cli-service lint"    },

希望这能解决您的问题。

在移动
package.json
后,您需要再次运行
cnpm install
againI,但它仍然不起作用……您是否检查了您的
package.json
是否确实包含
脚本
部分,其中包含
dev
命令?“脚本”{“测试”:“npm run lint--fix&&npm run test local”,“test local”:“蛋仓测试”,“lint”:“eslint bin lib test/*.js”,“ci”:“npm run lint&&npm run test”,“autod”:“autod”},它在脚本中不包含dev在移动
包之后。json
,您将需要再次运行
cnpm install
,但它仍然不起作用……您是否检查了您的
包。json
是否实际包含带有
dev
命令的
脚本部分?{“测试”:npm run lint--fix&&npm run test local,“test local”:“egg bin test”,“lint”:“eslint bin lib test/*.js”,“ci”:“npm run lint&&npm run test”,“autod”:“autod”},脚本中不包含开发人员