如何解决此错误:找不到模块“导入本地”

时间:2019-05-07 18:06:07

标签: javascript npm babel

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

Error: Cannot find module 'import-local'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
    at Function.Module._load (internal/modules/cjs/loader.js:520:25)

当我运行npm run start命令来运行我的项目forkify时,我得到了这个。

错误:模块构建失败(来自./node_modules/babel-loader/lib/index.js): TypeError:无法读取null的属性“绑定”     在Scope.moveBindingTo(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ scope \ index.js:864:13)     在convertBlockScopedToVar(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules \ babel-plugin-transform-es2015-block-scoping \ lib \ index.js:139: 13)     在PluginPass.VariableDeclaration(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules \ babel-plugin-transform-es2015-block-scoping \ lib \ index.js: 26:9)     在newFn(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ visitors.js:193:21)     在NodePath._call上(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ path \ context.js:53:20)     在NodePath.call上(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ path \ context.js:40:17)     在NodePath.visit(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ path \ context.js:88:12)     在TraversalContext.visitQueue(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ context.js:118:16)     在TraversalContext.visitSingle(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ context.js:90:19)     在TraversalContext.visit(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ context.js:146:19)     在Function.traverse.node(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ index.js:94:17)     在NodePath.visit(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ path \ context.js:95:18)     在TraversalContext.visitQueue(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ context.js:118:16)     在TraversalContext.visitMultiple(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ context.js:85:17)     在TraversalContext.visit(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ context.js:144:19)     在Function.traverse.node(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ index.js:94:17)     在NodePath.visit(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ path \ context.js:95:18)     在TraversalContext.visitQueue(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ context.js:118:16)     在TraversalContext.visitSingle(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ context.js:90:19)     在TraversalContext.visit(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ context.js:146:19)     在Function.traverse.node(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ index.js:94:17)     在遍历时(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ traverse \ lib \ index.js:76:12)     在transformFile(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ core \ lib \ transformation \ index.js:88:29)     在runSync处(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ core \ lib \ transformation \ index.js:45:3)     在runAsync(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ core \ lib \ transformation \ index.js:35:14)     在process.nextTick上(E:\ complete-javascript-course-master \ complete-javascript-course-master \ 9-forkify \ starter \ node_modules @ babel \ core \ lib \ transform.js:34:34)     在process._tickCallback(internal / process / next_tick.js:61:11)

我正在通过index.html文件的控制台获取该信息

2 个答案:

答案 0 :(得分:0)

使用lerna协调多个软件包时,我遇到了同样的问题。

可以说,您有一个这样的项目结构。

root
├── package.json
└── packages
    ├── first-project
    │   └── package.json
    └── second-project
        └── package.json

然后,您必须先在根文件夹上运行npm i,然后npm i进入要处理的项目,然后才能运行{{1 }}。

Lior已在评论中说过,但这可能对某人有帮助

答案 1 :(得分:0)

首先,运行

npm i

然后运行

npm audit fix