Azure Devops NPM 请将您的工作目录更改为有效目录

Posted

技术标签:

【中文标题】Azure Devops NPM 请将您的工作目录更改为有效目录【英文标题】:Azure Devops NPM Please change your working directory to a valid directory 【发布时间】:2019-08-09 12:38:04 【问题描述】:

我正在尝试使用 npm run-script build 构建一个项目

我的 package.json 是这样的


  "name": "isomorphic",
  "version": "2.6.0",
  "private": true,
  "dependencies": 
    "adal-angular": "^1.0.17",
    "antd": "^3.0.3",
    "antd-local-icon": "^0.1.3",
    "axios": "^0.18.0",
    "classnames": "^2.2.5",
    "clone": "^2.1.1",
    "history": "^4.6.3",
    "nprogress": "^0.2.0",
    "postcss-inline-rtl": "^0.9.8",
    "q": "^1.5.1",
    "react": "^16.2.0",
    "react-adal": "^0.4.17",
    "react-dom": "^16.2.0",
    "react-highlight-words": "^0.16.0",
    "react-intl": "^2.3.0",
    "react-placeholder": "^2.0.0",
    "react-redux": "^5.0.4",
    "react-router": "^4.1.1",
    "react-router-dom": "^4.1.0",
    "react-router-redux": "^5.0.0-alpha.5",
    "react-scripts": "1.0.17",
    "react-sidebar": "^2.3.2",
    "react-smooth-scrollbar": "^8.0.6",
    "react-throttle": "^0.3.0",
    "react-window-size-listener": "^1.0.10",
    "redux": "^3.6.0",
    "redux-devtools": "^3.3.2",
    "redux-devtools-dock-monitor": "^1.1.1",
    "redux-devtools-log-monitor": "^1.2.0",
    "redux-saga": "^0.16.0",
    "redux-thunk": "^2.2.0",
    "smooth-scrollbar": "^8.2.5",
    "styled-components": "^2.2.1",
    "styled-theme": "^0.3.3",
    "webpack-cli": "^3.2.3"
  ,
  "devDependencies": 
    "react-app-rewired": "^1.4.0",
    "webpack": "^4.29.5"
  ,
  "scripts": 
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test --env=jsdom",
    "eject": "react-scripts eject"
  

我的构建定义是这样的

但是我仍然收到此错误:

【问题讨论】:

【参考方案1】:

包含 package.json 的工作文件夹字段中,您指定了文件本身,而不是文件夹路径。您只需要将包含package.json 的文件夹路径放入即可。

【讨论】:

##[error]Error: ENOENT: no such file or directory, stat 'D:\a\1\s\$Build.SourcesDirectory' 将“”替换为“()” 谢谢,但现在我有很多其他错误,这很奇怪,因为本地相同的命令有效 ***.com/questions/55231041/… 不客气。我会检查你的另一个问题。【参考方案2】:

只需将“带有 package.json 的工作文件夹”字段留空

【讨论】:

【参考方案3】:

添加了版本为“6.9.1”的“节点工具安装程序” 使用以下自定义命令“install -g npm@latest”添加“Npm”

【讨论】:

以上是关于Azure Devops NPM 请将您的工作目录更改为有效目录的主要内容,如果未能解决你的问题,请参考以下文章

错误:请将您的依赖项升级到 core-js@3 的实际版本

Azure DevOps Server:还原被删除的分支

Azure DevOps Server:还原被删除的分支

OCR文本识别软件提示说无法对该语言执行OCR,请将您的OCR语言设置更改为可用的OCR语言是啥问题?

Azure Devops:即使在设置 NPM Authenticate 之后,也无法使用 NPM 私有注册表构建映像

使用 Visual Studio 构建任务在 azure devops 中设置工作目录