【发布时间】:2021-12-23 00:47:48
【问题描述】:
我是 JEST 的新手。我正在尝试获取,但要做到这一点,我必须导入它。但是,我遇到了这个错误:
Details:
/home/josecarlos/Workspace/BlueCode/server/node_modules/node-fetch/src/index.js:9
import http from 'node:http';
^^^^
SyntaxError: Unexpected identifier
1 | import config from "dotenv";
> 2 | import fetch from "node-fetch";
| ^
3 |
4 | config.config();
5 |
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)
at Object.<anonymous> (com/functions.js:2:1)
我的节点版本是:v11.15.0
这是我的依赖:
"dependencies": {
"cross-env": "^7.0.3",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"express-graphql": "^0.12.0",
"graphql": "^16.0.1",
"helmet": "^4.6.0",
"morgan": "^1.10.0",
"node-fetch": "^3.1.0"
},
"devDependencies": {
"@babel/cli": "^7.16.0",
"@babel/core": "^7.16.0",
"@babel/node": "^7.16.0",
"@babel/preset-env": "^7.16.0",
"jest": "^27.3.1",
"jshint": "^2.13.1",
"nodemon": "^2.0.14"
}
【问题讨论】:
-
我在不同的上下文中也遇到了这个包 'node:http' 的问题,但我似乎找不到关于这个模块的信息