简体   繁体   English

为什么会出现这个错误? “npm run dev 缺少脚本错误”

[英]Why does this error happen? "npm run dev missing script error"

I've been trying to follow the following tutorial: https://github.com/digitsensitive/phaser3-typescript/blob/master/README.md我一直在尝试遵循以下教程: https://github.com/digitsensitive/phaser3-typescript/blob/master/README.md

These are the steps that I had to follow这些是我必须遵循的步骤

Prerequisites Download and install npm with Node.js @ https://nodejs.org/en Installing Select a folder, navigate to it, and clone this repository with this command-line:先决条件 下载并安装 npm 和 Node.js @ https://nodejs.org/en安装 Select 一个文件夹,导航到它,然后使用此命令行克隆此存储库:

git clone https://github.com/digitsensitive/phaser3-typescript.git

Install the dependencies with this command-line:使用此命令行安装依赖项:

npm install

If you use yarn just replace npm with yarn如果您使用纱线,只需将 npm 替换为纱线

Building and Running Perform a quick build (bundle.js) and start server: npm run dev构建和运行执行快速构建 (bundle.js) 并启动服务器:npm run dev

I've never used node.js and npm before so I'm stumbling across some newbie mistakes.我以前从未使用过 node.js 和 npm,所以我遇到了一些新手错误。 One error I get is that when I try to run npm run dev, Git bash returns the following error code:我遇到的一个错误是,当我尝试运行 npm run dev 时,Git bash 返回以下错误代码:

npm ERR! missing script: dev

0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'dev' ]
2 info using npm@6.4.1
3 info using node@v10.15.3
4 verbose stack Error: missing script: dev
4 verbose stack at run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:155:19)
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:63:5
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:115:5
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:418:5
4 verbose stack at checkBinReferences_ (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:373:45)
4 verbose stack at final (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:416:3)
4 verbose stack at then (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:160:5)
4 verbose stack at ReadFileContext. (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:332:20)
4 verbose stack at ReadFileContext.callback (C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16)
4 verbose stack at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:237:13)
5 verbose cwd C:\Users\Yassi\TEST
6 verbose Windows_NT 10.0.17134

I don't know what I should be adding to my package.json file to make this work.我不知道我应该在我的 package.json 文件中添加什么来完成这项工作。 Could anyone help me with this please?有人可以帮我吗?

I made a package.json using init, but the tutorial doesn't state that I have to do this.我使用 init 制作了一个 package.json,但教程没有 state 我必须这样做。 I don't know why I should manually make a package.json file in the first place.我不知道为什么我首先要手动制作一个 package.json 文件。

Your package.json is missing a "dev" key in the scripts section. 您的package.json在脚本部分缺少“开发”键。 Or you are running the npm command from a wrong directory. 或者您从错误的目录运行npm命令。 Please use a package.json from their project. 请使用他们项目中的package.json。 I think this will work 我认为这会起作用

From here: https://github.com/digitsensitive/phaser3-typescript?files=1 从这里: https//github.com/digitsensitive/phaser3-typescript?files = 1

Just add div in scripts object in your package.json file as you see如您所见,只需在package.json文件中的脚本 object 中添加 div

"scripts": {
    "start": "node ./bin/www",
      "dev": "nodemon ./bin/www"
    },

that's if you use nodemon package那就是如果你使用nodemon package

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

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