问题描述
今天是 SPFx、Gulp 和 Yo 等的第一天。
尝试教程,但由于以下错误而失败:
mini-3:helloworld-webpart admin$ gulp serve
ReferenceError: primordials is not defined
at fs.js:45:5
at req_ (/playground/spfx/helloworld-webpart/node_modules/natives/index.js:143:24)
at Object.req [as require] (/playground/spfx/helloworld-webpart/node_modules/natives/index.js:55:10)
at Object.<anonymous> (/playground/spfx/helloworld-webpart/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:1:37)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (/playground/spfx/helloworld-webpart/node_modules/vinyl-fs/node_modules/graceful-fs/graceful-fs.js:3:27)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19)
About to exit with code: 1
Process terminated before summary Could be written,possible error in async code not continuing!
Trying to exit with exit code 1
以下是我目前采取的所有步骤:
正如您在尝试安装 npm 包时所看到的,我遇到了一堆错误,我不太确定如何解决。 另外...我尝试使用 node 12 版和 10 版。我无法安装/执行“yo”。我能够让你工作的唯一方法是使用节点 14。
任何建议都会有所帮助。我对 node、SPFx 和 npm 很陌生。如果我错过了一些简单的东西,我提前道歉。
编辑 1
我不小心得到了工作。我正在阅读有关 gulp 的内容,并尝试只运行“gulp”而不是“gulp serve”。这是我得到的:
mini-3:hello-new-world admin$ gulp
Build target: DEBUG
[14:31:45] Using gulpfile /playground/spfx/hello-new-world/gulpfile.js
[14:31:45] Starting 'default'...
[14:31:45] Starting gulp
[14:31:45] Starting subtask 'configure-sp-build-rig'...
[14:31:45] Finished subtask 'configure-sp-build-rig' after 2.53 ms
[14:31:45] Starting subtask 'pre-copy'...
[14:31:45] Finished subtask 'pre-copy' after 48 ms
[14:31:45] Starting subtask 'copy-static-assets'...
[14:31:45] Starting subtask 'sass'...
[14:31:45] Finished subtask 'copy-static-assets' after 23 ms
[14:31:45] Finished subtask 'sass' after 112 ms
[14:31:45] Starting subtask 'tslint'...
[14:31:45] [tslint] tslint version: 5.12.1
[14:31:45] Starting subtask 'tsc'...
[14:31:45] [tsc] typescript version: 3.7.7
[14:31:47] Finished subtask 'tsc' after 1.74 s
[14:31:47] Finished subtask 'tslint' after 2.3 s
[14:31:47] Starting subtask 'post-copy'...
[14:31:47] Finished subtask 'post-copy' after 105 μs
[14:31:47] Starting subtask 'configure-webpack'...
[14:31:47] Finished subtask 'configure-webpack' after 229 ms
[14:31:47] Starting subtask 'webpack'...
[14:31:48] Finished subtask 'webpack' after 673 ms
[14:31:48] Finished 'default' after 3.38 s
[14:31:49] ==================[ Finished ]==================
[14:31:49] Project hello-new-world version:0.0.1
[14:31:49] Build tools version:3.17.11
[14:31:49] Node version:v14.17.3
[14:31:49] Total duration:6.16 s
现在...... gulp serve 也可以使用了。
我不明白为什么。谁能解释一下?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)