【问题标题】:NPM errors when running npm run compile运行 npm run compile 时出现 NPM 错误
【发布时间】:2021-04-10 04:16:10
【问题描述】:

当我运行 npm run comile:js 时,我遇到了这个问题。那么该怎么办呢?

PS C:\Users\Marko\Desktop\storefrontdata-master\storefrontdata-master> npm run compile:js
npm ERR! missing script: compile:js

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Marko\AppData\Roaming\npm-cache\_logs\2021-01-04T11_00_45_777Z-debug.log
PS C:\Users\Marko\Desktop\storefrontdata-master\storefrontdata-master> 

如果可以的话,这就是我的 package.json 的外观:

{
  "name": "refarchdata",
  "version": "4.4.1",
  "description": "This is a repository for the data that goes with the ref arch storefront.",
  "main": "",
  "dependencies": {},
  "devDependencies": {},
  "scripts": {
    "zipData": "if [ -f demo_data_sfra.zip ] ; then rm -r demo_data_sfra.zip && zip -r demo_data_sfra.zip demo_data_sfra ; else zip -r demo_data_sfra.zip demo_data_sfra ; fi"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/SalesforceCommerceCloud/storefrontdata.git"
  },
  "author": "",
  "license": "ISC",
  "homepage": "https://github.com/SalesforceCommerceCloud/storefrontdata"
}

【问题讨论】:

  • 检查文件夹路径是否正确。是C:\Users\Marko\Desktop\storefrontdata-master里面的文件吗?
  • @MatJ 我改变了路径,但我现在得到了这个:PS C:\Users\Marko\Desktop\storefrontdata-master\storefrontdata-master> npm run compile:js npm ERR!缺少脚本:编译:js npm ERR!可以在以下位置找到此运行的完整日志:npm ERR! C:\Users\Marko\AppData\Roaming\npm-cache_logs\2021-01-04T11_00_45_777Z-debug.log PS C:\Users\Marko\Desktop\storefrontdata-master\storefrontdata-master>

标签: node.js npm npm-run


【解决方案1】:

错误已经告诉了你原因:

no such file or directory, open 'C:\Users\Marko\Desktop\storefrontdata-master\package.json'

您的项目没有package.json 文件。请确保你有一个。

更新后更新:打开 package.json(如果有),然后查找 scripts 并确保 compile:js 在它下面。该文件应如下所示:

// package.json
 {
  .....
 scripts : {
     "compile:js": "....",
 }
  ....

 }

【讨论】:

  • 我改变了路径,所以如果你现在可以看到我在运行编译时得到了什么。
  • 我更新了我的答案。如果阅读他们首先抛出的错误日志的含义,你也会找到你的。
  • 谢谢。如果您可以看到我的 package.json 文件,我添加了问题
  • 正如我上面所说,scripts 下是您可以运行的所有命令。在您的 package.json 中,zipData 是您可以运行的唯一命令 npm run zipData @markk
【解决方案2】:

您应该在文件 package.json 中添加一个脚本才能运行 作为这个形状 npm 运行编译 它将检查 package.json 中是否有脚本,然后运行它 像这样

{
  //some code
 scripts : {
     "compile:js": "waht you need to put here",
 }
 

 }

如果你想运行文件他的名字 compile.js 使用 node 与文件的位置 像这样node compile.js

【讨论】:

    猜你喜欢
    • 2021-03-03
    • 2020-06-15
    • 1970-01-01
    • 2021-08-10
    • 2022-01-23
    • 1970-01-01
    • 2023-02-02
    • 2021-07-14
    • 2018-12-12
    相关资源
    最近更新 更多