Parcel: bug: global installation via pnpm cannot find modules

Created on 1 Jan 2018  路  5Comments  路  Source: parcel-bundler/parcel

Choose one: 馃悰 bug report

馃帥 Configuration (.babelrc, package.json, cli command)


No babel configuration, it's my first install and I just wanted to try it out.

馃 Expected Behavior


Running parcel index.html should start the live server.

馃槸 Current Behavior


Build fails with an error about missing modules. Running pnpm install -g posthtml-parser fixed the first one, but then it complains about posthtml-render.

馃毃  Cannot find module 'posthtml-parser'
    at Function.Module._resolveFilename (module.js:489:15)
    at Function.Module._load (module.js:439:25)
    at Module.require (module.js:517:17)
    at require (/home/vortex/.nvm/versions/node/v8.3.0/pnpm-global/1/node_modules/.registry.npmjs.org/v8-compile-cache/1.1.0/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/home/vortex/.nvm/versions/node/v8.3.0/pnpm-global/1/node_modules/.registry.npmjs.org/parcel-bundler/1.4.0/node_modules/parcel-bundler/src/assets/HTMLAsset.js:2:15)
    at Module._compile (/home/vortex/.nvm/versions/node/v8.3.0/pnpm-global/1/node_modules/.registry.npmjs.org/v8-compile-cache/1.1.0/node_modules/v8-compile-cache/v8-compile-cache.js:178:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)

馃拋 Possible Solution


it seems this is as a result of pnpm not flattening dependencies.

馃敠 Context

馃捇 Code Sample

馃實 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.4.0
| Node | 8..3.0
| pnpm | 1.25.1
| Operating System | Peppermint 8 Linux

Bug Confirmed Bug

All 5 comments

Same error here, by not installing parcel globally as this is an antipattern.

I suppose the reason is that parcel-bundle directly requires the following modules:

  • babel-code-frame
  • babel-template
  • babel-traverse
  • babel-types
  • posthtml-parser
  • posthtml-render

but doesn't mention them in its package.json

See pnpm/pnpm#968

I believe one should add the following lines to package.json:

  "devDependencies": {
    "babel-code-frame": "^6.26.0",
    "babel-template": "^6.26.0",
    "babel-traverse": "^6.26.0",
    "babel-types": "^6.26.0",
    "posthtml-parser": "^0.4.0",
    "posthtml-render": "^1.1.0",

Oh, babel-template and babel-types have already been added in #727

Having the same issue. Modules that are direct dependencies should be listed as so in the package.json.

It seems this issue still exist with the version 1.12.4 of parcel :

(node:26544) UnhandledPromiseRejectionWarning: Error: Cannot find module 'babel-types'

I noticed that ./src/Asset.js requires directly babel-types whereas it's not declared as direct dependency in the package.json

@yoanthiebault - it's the same reason i'm seeing an error when tap/bin/jack.js attempt to load treport/types on line 8. (tap v14.10.8). treport/types is not declared as a dependency in package.json.

Was this page helpful?
0 / 5 - 0 ratings