我正在使用,ts-node但它给了我这个错误:
$ ts-node index.ts
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /home/projects/node-hddds8/index.ts
Run Code Online (Sandbox Code Playgroud)
我尝试"type": "module"从我的中删除package.json,但在这种情况下我收到了不同的错误:
$ ts-node index.ts
(node:45) 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)
/home/projects/node-hddds8/index.ts:1
import chalk from 'chalk';
^^^^^^
SyntaxError: Cannot use import statement outside a module
Run Code Online (Sandbox Code Playgroud)
以下是 StackBlitz 上的复制链接:https ://stackblitz.com/edit/node-hddds8?file=index.ts
我的package.json如下所示:
{
"name": "node-starter",
"version": "0.0.0",
"type": …Run Code Online (Sandbox Code Playgroud) 我正在尝试更改生产构建的公共路径,但似乎无法使其正常工作。当我进行生产构建时,我想将公共路径从 更改/为./,但我在文档中找不到如何执行此操作的任何内容。我使用vite.js作为我的构建工具。也许这是 Vue 3 和 Vite 特有的,我不确定。
我尝试添加vue.config.js文件和.env变量,但到目前为止没有任何效果。
当我构建时,我得到以下输出,路径开头为/:
<head>
<script src="/assets/index.30c61b3b.js"></script>
<link href="/assets/vendor.29497e16.js">
<link href="/assets/index.7123a98f.css">
</head>
Run Code Online (Sandbox Code Playgroud)
但对于生产我希望它改为./这样:
<head>
<script src="./assets/index.30c61b3b.js"></script>
<link href="./assets/vendor.29497e16.js">
<link href="./assets/index.7123a98f.css">
</head>
Run Code Online (Sandbox Code Playgroud)
我尝试添加vue.config.js但没有帮助:
module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? './' : '/'
}
Run Code Online (Sandbox Code Playgroud)
并且.env
NODE_ENV=production
BASE_URL=./
Run Code Online (Sandbox Code Playgroud) Grep 通常以红色显示突出显示的文本,这正是我想要的,但这次无论我做什么它似乎都不会这样做。我是从 Docker 容器(nginx:1.19-alpine更具体地说)执行此操作,并使用RUN apk add bash. 然后我添加了一个~/.bashrc包含以下内容的配置文件:
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
force_color_prompt=yes
color_prompt=yes
if [ "$color_prompt" = yes ]; then
PS1=' ${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@server-nginx\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1=' ${debian_chroot:+($debian_chroot)}\u@server-nginx:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@server-nginx: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and …Run Code Online (Sandbox Code Playgroud)