Error: Cannot find module 'MyPromise.js'

出现如下错误:

internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'MyPromise.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (G:\web\es6\test\dist\/TestMyPromise.js:5:41)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Module._compile (G:\web\es6\test\node_modules\pirates\lib\index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.newLoader [as .js] (G:\web\es6\test\node_modules\pirates\lib\index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@1.0.0 running: `babel-node ./dist/TestMyPromise.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the test@1.0.0 running 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!     C:\Users\34973\AppData\Roaming\npm-cache\_logs\2020-04-25T13_50_55_382Z-debug.log

Process finished with exit code 1

可能的解决方案

同一目录下的文件,比如:
在这里插入图片描述

可能你的引入方式错了,如下:

import Promise from "MyPromise";

正确的方式应该是这样的:

import Promise from "./MyPromise";
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值