Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js JestJS.io:TypeError[ERR\u INVALID\u FILE\u URL\u PATH]:文件URL路径必须是绝对路径_Node.js_Npm_Jestjs - Fatal编程技术网

Node.js JestJS.io:TypeError[ERR\u INVALID\u FILE\u URL\u PATH]:文件URL路径必须是绝对路径

Node.js JestJS.io:TypeError[ERR\u INVALID\u FILE\u URL\u PATH]:文件URL路径必须是绝对路径,node.js,npm,jestjs,Node.js,Npm,Jestjs,我在Windows10上重新安装了NodeJS,并尝试安装JEST(jestjs.io),它是通过重复调用 npm install --save-dev jest 及 因为它抱怨巴别塔和其他类型。我重复了这两个命令,然后它没有出现错误,说安装了更多的软件包。 当我运行求和测试时 mh@CL MINGW64 /h/RR_NodeJS/JEST $ npm run test > @ test H:\RR_NodeJS > jest FAIL JEST/sum.test.js

我在Windows10上重新安装了NodeJS,并尝试安装JEST(jestjs.io),它是通过重复调用

npm install --save-dev jest

因为它抱怨巴别塔和其他类型。我重复了这两个命令,然后它没有出现错误,说安装了更多的软件包。 当我运行求和测试时

mh@CL MINGW64 /h/RR_NodeJS/JEST
$ npm run test

> @ test H:\RR_NodeJS
> jest

 FAIL  JEST/sum.test.js
  ● Test suite failed to run

    TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute



Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.754 s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ test: `jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\mh\AppData\Roaming\npm-cache\_logs\2020-10-13T16_02_40_985Z-debug.log
我已经将路径解析为Visual Studio代码建议的绝对路径:

function sum(a, b) {
  return a + b;
}
export default sum;
(最后一行)和


但是,仍然会收到相同的错误消息,并且测试没有成功。我已经尝试了另一个安装,在那里我安装了through Thread,而不是npm,结果也出现了同样的错误。我在stackoverflow和其他页面上找到了关于错误消息的类似报告,但没有一个帮助我运行它。我应该怎么做才能让它运行?

请有人给我一个建议好吗?
function sum(a, b) {
  return a + b;
}
export default sum;
import sum from '/h/RR_NodeJS/JEST/sum';

test('adds 1 + 2 to equal 3', () => {
  expect(sum(1, 2)).toBe(3);
});