./ansi-html 中的错误 1:0 模块解析失败:意外字符“#"(1:0) [英] ERROR in ./ansi-html 1:0 Module parse failed: Unexpected character '#' (1:0)

查看:49
本文介绍了./ansi-html 中的错误 1:0 模块解析失败:意外字符“#"(1:0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 angular js.当我运行 ng serve --open 时出现以下错误

I am learning angular js. When I run ng serve --open I get below error

ERROR in ./ansi-html 1:0
Module parse failed: Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type
> #!/bin/sh
| basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

angular CLI 版本为 6.2.0

节点版本为 8.11.4

npm 版本是 6.4.1

ansi-html 文件为

ansi-html file is as

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/node_modules/ansi-html/bin/ansi-html" "$@"
  ret=$?
else 
  node  "$basedir/node_modules/ansi-html/bin/ansi-html" "$@"
  ret=$?
fi
exit $ret

如果我删除第一行,则错误是

If I remove first line then error is

ERROR in ./ansi-html 1:18
Module parse failed: Unexpected token (1:18)
You may need an appropriate loader to handle this file type.
> basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
| case `uname` in
i ?wdm?: Failed to compile.

推荐答案

大家好!今年早些时候,我在我的 Windows 机器(Windows 10 企业版)上遇到了同样的问题.

Alright everyone! I faced same problem earlier this year on my windows machine(Windows 10 Enterprise).

原因?

我不知道为什么会这样.

I have no idea why the hell this happened.

解决方案?

你必须从你的机器上完全卸载 node.js.

You have to completely uninstall node.js from your machine.

我是如何解决我的问题的?

  1. 首先,我使用以下命令清理缓存:npm cache clean--force" 不带引号.
  2. 其次,我使用 iobit 卸载程序软件卸载了 node.js(我只是明确表示没关系).

  1. First, i did a cache clean using this command: "npm cache clean --force" without quotes.
  2. Second, i uninstalled node.js using iobit uninstaller software(i'm just being explicit it doesn't matter).

第三,我删除了nmp-cache文件夹在 C:\Users\YOURNAME\AppData\Roaming

Third, i deleted nmp-cache folder in C:\Users\YOURNAME\AppData\Roaming

现在,重新启动您的计算机;访问 https://nodejs.org 并下载一个新的 node.js 安装程序,在安装过程中你会被问到您想为 node.js 安装其他工具,请跳过并继续完成.确认您已成功安装 node.js,运行以下命令:"node --version && npm --version" 不带引号.你应该得到这样的东西:

Now, restart your computer; visit https://nodejs.org and download a fresh node.js installer, during the installation you'll be asked if you'd like to install additional tools for node.js, please skip and proceed to finish. Confirm you have successfully installed node.js, run this command: "node --version && npm --version" without quotes. You should get something like this:

v11.11.0

6.7.0

如果此时一切正常,请随意安装您的 angular;命令:npm install -g @angular/cli"不带引号(-g 标志将全局安装它,这样你就可以从你电脑的任何地方创建一个新的 angular 项目).再次确认安装;运行:ng --version",你应该有这样的东西:

If everything is all good at this point, feel free to install your angular; command: "npm install -g @angular/cli" without quotes(the -g flag will install it globally so you could create a new angular project from anywhere on your pc). Again, confirm installation; run: "ng --version", you should have something like this:

Angular CLI:7.3.6

Angular CLI: 7.3.6

节点:11.11.0

操作系统:win32 x64

OS: win32 x64

角度:7.2.9

继续创建一个新的 angular 项目,就在你这样做之前;确保您当前位于正确的目录中.命令:"ng new project-name" 不带引号(project-name 是你想命名你的项目).成功安装后,通过打开项目目录运行您的项目,例如cd project-name"不带引号,然后ng serve --open"(--open 标志在您的默认网络浏览器中打开项目,需要几秒钟).

Go ahead and create a new angular project, just before you do that; be sure you are currently in the right directory. Command: "ng new project-name" without quotes(project-name is what you wanna name your project). After a successful installation run your project by opening the project directory e.g "cd project-name" without quotes and then "ng serve --open"(--open flag opens the project in your default web browser, will take a few seconds).

干杯.

这篇关于./ansi-html 中的错误 1:0 模块解析失败:意外字符“#"(1:0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆