npm start使用意外标记ILLEGAL给出了奇怪的错误8

时间:2016-09-22 12:58:39

标签: node.js npm-start

在进行$ npm start

时,我得到了奇怪的错误8,输出低于输出
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
npm ERR! weird error 8
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! not ok code 0

npm -v 1.3.10

节点-v v0.10.25

我已经安装了nodejs-legacy

$ which node
/usr/bin/node

$ which nodejs
/usr/bin/nodejs

有人可以帮忙吗。

我正在尝试在ubuntu 14.04上运行react-jsonschema-form或word-finder(https://github.com/amirrajan/word-finder

1 个答案:

答案 0 :(得分:1)

您正在使用节点0.10 - 目前LTS版本是4.5.0,当前版本是6.6.0。考虑升级Node,因为您使用的是非常过时的版本。节点0.10于2013年3月发布,其维护期在一周内结束(2016年10月1日),然后它将不再获得任何更新,请参阅:https://github.com/nodejs/LTS#lts_schedule

根据package.json中的github.com/mozilla-services/react-jsonschema-form,所需的节点版本至少为6.x和npm 2.14.7。您正尝试在Node v0.10.25和npm 1.3.10上运行它。你不应该期望它能够发挥作用。

要安装现代版本的Node,您可以从https://nodejs.org/下载二进制版本,也可以从源代码构建它,例如使用与此类似的过程:

如果您希望在node中安装/usr/local并以/usr/local/bin/node的形式提供,则可以执行以下操作:

# change dir to your home:
cd ~
# download the source:
curl -O https://nodejs.org/dist/v6.6.0/node-v6.6.0.tar.gz
# extract the archive:
tar xzvf node-v6.6.0.tar.gz
# go into the extracted dir:
cd node-v6.6.0
# configure for installation:
./configure --prefix=/usr/local
# build and test:
make && make test
# install:
sudo make install
# make sure you have /usr/local/bin in your $PATH before /usr/bin:
# add this to your .profile or .bashrc:
PATH="/usr/local/bin:$PATH"

或者如果您希望能够同时安装几个版本,并使用符号链接到默认值:

# change dir to your home:
cd ~
# download the source:
curl -O https://nodejs.org/dist/v6.6.0/node-v6.6.0.tar.gz
# extract the archive:
tar xzvf node-v6.6.0.tar.gz
# go into the extracted dir:
cd node-v6.6.0
# configure for installation:
./configure --prefix=/opt/node-v6.6.0
# build and test:
make && make test
# install:
sudo make install
# make a symlink to that version:
sudo ln -svf /opt/node-v6.6.0 /opt/node
# make sure you have /opt/node/bin in your $PATH before /usr/bin
# add this to your .profile or .bashrc:
PATH="/opt/node/bin:$PATH"

有关详细信息,请参阅this answer