微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

运行 npm run compile 时出现 NPM 错误

如何解决运行 npm run compile 时出现 NPM 错误

当我运行 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"
}

解决方法

错误已经告诉你原因了:

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 文件中添加一个脚本才能运行 作为这个形状 npm 运行编译 它将检查 package.json 中是否有脚本然后运行它 像这样

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

 }

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。