我无法让npm工作.我的Package.json文件

"scripts": { "build": "build.js" }

我有个身材.js文件位于与控制台相同的文件夹中.日志(log).

当我跑的时候

npm run build

我明白了

The system cannot execute the specified program.

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v4.1.1
npm ERR! npm  v3.3.5
npm ERR! code ELIFECYCLE

如果我移动建筑.js文件并更改我的包.json文件有一个子文件夹

"scripts": { "build": "build/build.js" }

then 我明白了

'build' is not recognized as an internal or external command, operable program or batch file.

怎么了?我在抄example documentation.

推荐答案

{ "scripts" :
  { "build": "node build.js"}
}

npm run buildnpm run-script build


{
  "name": "build",
  "version": "1.0.0",
  "scripts": {
    "start": "node build.js"
  }
}

npm start


NB:你错过了{ brackets }node指令

文件夹 struct 很好:

+ build
  - package.json
  - build.js

Node.js相关问答推荐

在Cypress测试文件中获取项目根路径

Node.js PNG缓冲区获取未知图像格式错误

购物车是空的状态|本地存储不更新产品数量|Redux|

使用Node.js中的";类型";:";模块";不导入文件

Prisma 和 Nextjs:重新部署之前内容不会更新

try 使用 pdf.js 时 pdf.getPage 不是函数

在 Nest 项目上运行 Jest 测试时,我的文件无法找到一个在测试之外没有任何问题的模块

如何在mongoose 聚合中执行全文搜索

TypeError:在使用 Jest、Supertest、Express、Typescript 进行测试时无法读取未定义的属性(读取listen)

kubernetes 上的 nextjs 无法启动

将已保存的卡片从条带显示到前端

discordjs如何添加所有意图/权限

如何在 NodeJS 中获取操作系统用户名?

如何使用 gulp-uglify 缩小 ES6 函数?

如何在 Node.js 中使用 chmod

如何在 MongoDB 中查询引用的对象?

使用 node.js 循环 JSON

从 node.js 连接到 mongodb 时出现 ECONNREFUSED 错误

在 Node.js 中获取终端的宽度

mongoose 填充与对象嵌套