我不明白出了什么问题.节点v5.6.0 NPM v3.10.6
代码:
function (exports, require, module, __filename, __dirname) {
import express from 'express'
};
Run Code Online (Sandbox Code Playgroud)
错误:
SyntaxError: Unexpected token import
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:140:18)
at node.js:1001:3
Run Code Online (Sandbox Code Playgroud) 我试图在桌面上运行这个存储库一个 vscode 扩展。
我在本地克隆它并运行 npm install
在 vscode 编辑器上按 f5 并出现错误
Process exited with code 1
(node:1404) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
internal/process/warning:44
Canceled
Run Code Online (Sandbox Code Playgroud)
为了解决这个警告,我发现了另一个 stackoverflow 问题 - (node:9374) 警告:要加载 ES 模块,请设置 "type": "module"
所以我设置"type":"module"上package.json,然后按F5一次。
并出现另一个错误。
Process exited with code 1
Uncaught TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /mnt/c/vscode-php-debug/src/phpDebug.ts
Run Code Online (Sandbox Code Playgroud)
并在 …