Skip to content

The requested module 'pytorchjs' is a CommonJS module, which may not support all module.exports as named exports #22

@raphael10-collab

Description

@raphael10-collab
(base) raphy@pc:~/pytorchjsPlay$ nano basic.js

import { torch, torchvision } from 'pytorchjs';

(base) raphy@pc:~/pytorchjsPlay$ node basic.js 
file:///home/raphy/pytorchjsPlay/basic.js:1
import { torch, torchvision } from 'pytorchjs';
         ^^^^^
SyntaxError: Named export 'torch' not found. The requested module 'pytorchjs' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'pytorchjs';
const { torch, torchvision } = pkg;

    at ModuleJob._instantiate (internal/modules/esm/module_job.js:104:21)
    at async ModuleJob.run (internal/modules/esm/module_job.js:149:5)
    at async Loader.import (internal/modules/esm/loader.js:166:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)
(base) raphy@pc:~/pytorchjsPlay$ 

basic_2,js :

import pkg from 'pytorchjs';
const { torch, torchvision } = pkg;


(base) raphy@pc:~/pytorchjsPlay$ node basic_2.js 
internal/modules/cjs/loader.js:880
  const err = new Error(message);
              ^

Error: Cannot find module '@babel/runtime/helpers/interopRequireDefault'
Require stack:
- /home/raphy/pytorchjsPlay/node_modules/pytorchjs/lib/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/home/raphy/pytorchjsPlay/node_modules/pytorchjs/lib/index.js:3:30)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:199:29) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/raphy/pytorchjsPlay/node_modules/pytorchjs/lib/index.js' ]
}
(base) raphy@pc:~/pytorchjsPlay$ 

package.json :

{
"type": "module",
"dependencies": {
"pytorchjs": "^0.1.5"
}
}

node : v14.15.5
OS. Ubuntu 20.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions