dojo / meta

:rocket: Dojo - meta information for the project.
Other
226 stars 50 forks source link

Dojo cli breaks when installing cli-build-app or cli-build-widget #261

Closed dannygorton closed 6 years ago

dannygorton commented 6 years ago

I'm trying to get started with dojo2 for a project rewrite from adhoc javascript + jquery. I'm trying to go through the tutorial here: https://dojo.io/tutorials/000_local_installation/. This is currently a Windows 10 machine. I tried yesterday on my Ubuntu 16.04 machine with NodeJS v8.x and v10.x, with very similar issues. I have installed the latest NodeJS LTS package:

C:\Users\danno>node --version
v8.11.3

I have installed @dojo/cli and @dojo/cli-create-app:

C:\Users\danno>dojo --version
2.0.0

Running 'dojo' I can see the ASCII art and the list of commands, but after I install cli-build-app I get the following when I run 'dojo':

C:\Users\danno>npm install -g @dojo/cli-build-app
npm WARN deprecated postcss-cssnext@3.1.0: 'postcss-cssnext' has been deprecated in favor of 'postcss-preset-env'. Read more at https://moox.io/blog/deprecating-cssnext/
npm WARN deprecated @types/source-map@0.5.7: This is a stub types definition for source-map (https://github.com/mozilla/source-map). source-map provides its own type definitions, so you don't need @types/source-map installed!

> uglifyjs-webpack-plugin@0.4.6 postinstall C:\Users\danno\AppData\Roaming\npm\node_modules\@dojo\cli-build-app\node_modules\webpack\node_modules\uglifyjs-webpack-plugin
> node lib/post_install.js

npm WARN @theintern/istanbul-loader@1.0.0-beta.1 requires a peer of webpack@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @theintern/istanbul-loader@1.0.0-beta.1 requires a peer of intern@^4.0.0-alpha.16 but none is installed. You must install peer dependencies yourself.
npm WARN @theintern/istanbul-loader@1.0.0-beta.1 requires a peer of istanbul-lib-instrument@^1.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @dojo/shim@2.0.0 requires a peer of @dojo/has@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\@dojo\cli-build-app\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @dojo/cli-build-app@2.0.1
added 1293 packages in 74.824s

C:\Users\danno>dojo
Commands are not available: Error: Failed to load module C:/Users/danno/AppData/Roaming/npm/node_modules/@dojo/cli-build-app
Nested error: Cannot find module '@dojo/core/lang'

I tried removing cli-build-app and installing cli-build-widget, then I get the following when I run 'dojo':

C:\Users\danno>npm install -g @dojo/cli-build-widget
npm WARN deprecated postcss-cssnext@3.1.0: 'postcss-cssnext' has been deprecated in favor of 'postcss-preset-env'. Read more at https://moox.io/blog/deprecating-cssnext/
npm WARN deprecated @types/source-map@0.5.7: This is a stub types definition for source-map (https://github.com/mozilla/source-map). source-map provides its own type definitions, so you don't need @types/source-map installed!

> uglifyjs-webpack-plugin@0.4.6 postinstall C:\Users\danno\AppData\Roaming\npm\node_modules\@dojo\cli-build-widget\node_modules\webpack\node_modules\uglifyjs-webpack-plugin
> node lib/post_install.js

npm WARN @theintern/istanbul-loader@1.0.0-beta.1 requires a peer of webpack@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @theintern/istanbul-loader@1.0.0-beta.1 requires a peer of intern@^4.0.0-alpha.16 but none is installed. You must install peer dependencies yourself.
npm WARN @theintern/istanbul-loader@1.0.0-beta.1 requires a peer of istanbul-lib-instrument@^1.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\@dojo\cli-build-widget\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @dojo/cli-build-widget@2.0.2
added 1221 packages in 65.77s

C:\Users\danno>dojo
Commands are not available: TypeError: Failed to load module C:/Users/danno/AppData/Roaming/npm/node_modules/@dojo/cli-build-widget
Nested error: Path must be a string. Received null

Any ideas on what I'm doing wrong?

maier49 commented 6 years ago

You shouldn't need to globally install @dojo/cli-build-app or @dojo/cli-build-widget. After installing @dojo/cli and @dojo/cli-create-app you should be able to run dojo create app --name first-dojo-2-app as mentioned in that tutorial, and @dojo/cli-build-app will be locally installed in that app as part of the setup process.

After dojo create app finishes setting up the project you should be able to run dojo build from within the project folder.

dannygorton commented 6 years ago

Thanks for that. I was able to complete the installation and demo on my Windows machine. Here's where my confusion came from. I did those exact steps per the tutorial on my Ubuntu Xenial machine. I got this response:

danno@panther:~/dev/dojotest$ dojo build --mode dev --watch --serve
Unknown arguments: mode, watch, serve

<snipped>ascii art</snipped>

Usage:

  $ dojo build [<command>] [<options>] [--help]

Commands:

  build      app         CLI command to build Dojo 2 applications (Default)
             widget      CLI command to build Dojo 2 custom elements

Default Command Options

  To install this command run npm i @dojo/cli-build-app

Based on this part of the tutorial, I thought I needed to install cli-build-app:

Running dojo will show all available commands even if they are not installed, when you try to run a command that is not available the CLI will print a message that the command needs to be installed.

Doing so leads to the issue I reported here. It also shows that the install doesn't work as several unmet peer dependencies exist (has, intern, instanbul, webpack) and several other warnings (deprecated, optional and notsup) about other dependencies.

I have since upgraded to Ubuntu Bionic (18.04), nodejs v8.10.0 (from Ubuntu repo), dojo v2.0.0 and get the similar results as before. So it works as expected on Windows but not on Ubuntu 16.04 or 18.04.

dannygorton commented 6 years ago

I'm closing this because the issue seems to be only on my Linux distro and this issue was about both, and my confusion of how dojo cli works.