Parcel js 不能 运行 Ubuntu 上的同一个项目

Parcel js can't run same project on Ubuntu

我在 JavaScript 中有一个项目可以在 Windows 上与 parcel 2 bundler 一起工作。但是当我尝试 运行 Ubuntu 中的相同代码时,它不起作用并给出错误。在这里,我给出了错误和 package.json。我搜索了很多地方并尝试了很多解决方案,例如清理缓存和重新安装,但它们没有帮助。正如我所说,这适用于 Windows.

我尝试 运行 npm run dev

时遇到的错误
ffa@ffa-ubuntu:~/Desktop/javascript-forkify$ npm run dev

> forkify@1.0.0 dev /home/ffa/Desktop/javascript-forkify
> parcel index.html

/home/ffa/Desktop/javascript-forkify/node_modules/@parcel/core/lib/Parcel.js:149
  #requestTracker
  ^

SyntaxError: Invalid or unexpected token
    at new Script (vm.js:83:7)
    at NativeCompileCache._moduleCompile (/home/ffa/Desktop/javascript-forkify/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
    at Module._compile (/home/ffa/Desktop/javascript-forkify/node_modules/v8-compile-cache/v8-compile-cache.js:184:36)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (/home/ffa/Desktop/javascript-forkify/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/home/ffa/Desktop/javascript-forkify/node_modules/@parcel/core/lib/index.js:75:39)
/home/ffa/Desktop/javascript-forkify/node_modules/@parcel/logger/lib/Logger.js:41
  #logEmitter
  ^

SyntaxError: Invalid or unexpected token
    at new Script (vm.js:83:7)
    at NativeCompileCache._moduleCompile (/home/ffa/Desktop/javascript-forkify/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
    at Module._compile (/home/ffa/Desktop/javascript-forkify/node_modules/v8-compile-cache/v8-compile-cache.js:184:36)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at _logger (/home/ffa/Desktop/javascript-forkify/node_modules/parcel/lib/cli.js:54:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! forkify@1.0.0 dev: `parcel index.html`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the forkify@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ffa/.npm/_logs/2021-08-16T10_32_03_227Z-debug.log

package.json

{
  "name": "forkify",
  "version": "1.0.0",
  "description": "",
  "default": "index.html",
  "scripts": {
    "dev": "parcel index.html",
    "build": "parcel build index.html --dist-dir dist",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Fatih Furkan Aydemir",
  "license": "ISC",
  "devDependencies": {
    "parcel": "^2.0.0-rc.0",
    "sass": "^1.37.5"
  },
  "dependencies": {
    "core-js": "^3.16.1",
    "regenerator-runtime": "^0.13.9"
  }
}

文件夹结构

forkify-architecture-recipe-loading.png
forkify-flowchart-part-1.png
forkify-flowchart-part-2.png
forkify-flowchart-part-3.png
index.html
node_modules
package.json
package-lock.json
page.png
README.md
src

我找到问题了。我已经通过 apt 安装了 npm 和节点。安装的nodejs版本是10.19.0。但实际上node js网站上的最新版本是14.17.5。于是从官网下载了源码,自己搭建,用make安装。然后就成功了。